ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Vole_Population_Manager Class Reference

The class to handle all vole population related matters. More...

#include <VolePopulationManager.h>

Inheritance diagram for Vole_Population_Manager:
Population_Manager

Public Member Functions

uint32 GetVoleAllele (int a_list, int a_vole, int a_locus, int a_chromosome)
 used to get a specific vole allele from outside the population manager More...
 
virtual void ImpactedProbe ()
 
bool IsTrap (int p_x, int p_y)
 
void TheAgeSexLocationProbe ()
 
virtual void TheAOROutputProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual void TheReallyBigOutputProbe ()
 
virtual void TheSexRatiosProbe ()
 
virtual void LandscapeQuadrantOutputProbe (int a_day)
 
void AddToFrag1Male ()
 
void AddToFrag1Female ()
 
void AddToFrag2Male ()
 
void AddToFrag2Female ()
 
void AddToFrag3Male ()
 
void AddToFrag3Female ()
 
 Vole_Population_Manager (Landscape *p_L)
 
virtual ~Vole_Population_Manager ()
 
void CreateObjects (VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
 
void CreateObjects_Init (VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
 
virtual void Init (void)
 
bool RecordGeneticsToday (int p_today, int p_year, int p_start_year, int p_interval)
 
double GetHabitatQuality (int a_index)
 
bool SupplyOlderFemales (unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_range)
 
int SupplyHowManyVoles (unsigned p_x, unsigned p_y, unsigned p_size)
 
int SupplyGrowthStartDate ()
 
int SupplyInOlderTerr (unsigned p_x, unsigned p_y, unsigned p_Age, unsigned p_Range)
 
int SupplyCountFemales (unsigned p_x, unsigned p_y, unsigned p_TerrRange)
 
void SendMessage (TTypeOfVoleMessage p_message, unsigned p_x, unsigned p_y, unsigned p_range, bool p_sex, double p_Weight)
 
vector< Vole_Base * > * SupplyVoleList (unsigned x, unsigned y, unsigned range)
 
bool InSquare (int p_x, int p_y, int p_sqx, int p_sqy, int p_range)
 
int ListClosestFemales (int p_x, int p_y, int p_steps)
 
int ListClosestMales (int p_x, int p_y, int p_steps)
 
Vole_FemaleFindClosestFemale (int p_x, int p_y, int p_steps)
 
Vole_MaleFindClosestMale (int p_x, int p_y, int p_steps)
 
Vole_MaleFindRandomMale ()
 
void AddToYoung (int young)
 
Vole_MaleFindWithinRadiusMale (int p_x, int p_y)
 
Vole_MaleFindOutsideRadiusMale (int p_x, int p_y)
 
bool BarrierSearch (int F_x, int F_y, int M_x, int M_y)
 
void AddToYoungYr (int young)
 
void AddToJuvs (int juvs)
 
void AddToNoYoungInfanticideCount (int m_NoOfYoung, int m_YoungAge)
 
void ReproductionProbe ()
 
void GeneticsOutputFile (unsigned listindex)
 
virtual void GeneticsResultsOutput (FILE *ofile, unsigned listindex)
 
void OpenResistanceOutput ()
 Opens the output file ready for resistance results. More...
 
void CloseResistanceOutput ()
 Closes the output file ready for resistance results. More...
 
void ResistanceOutput ()
 Resistance results file output
More...
 
- Public Member Functions inherited from Population_Manager
 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual void Run (int NoTSteps)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
int SupplyListNameLength ()
 
TAnimalSupplyAnimalPtr (int a_index, int a_animal)
 Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More...
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe (string a_NWordFilename)
 
void OpenTheAOROutputProbe (string a_AORFilename)
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
virtual void CloseTheRipleysOutputProbe ()
 
virtual void CloseTheReallyBigOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 

Public Attributes

VoleSummaryOutputm_VoleRecordMort
 
FILE * SexRatiosPrb
 
int ReproTable [4][12]
 
unsigned IDNumber
 
Vole_FemaleList FList
 
Vole_MaleList MList
 
AlleleFreqAFreq
 
int YoungProducedToday
 
int JuvsProducedToday
 
int NoYoungKilledToday
 
int NoYoungKilledToday4
 
int NoYoungKilledToday8
 
int NoYoungKilledToday9
 
FILE * YoungsFile
 
IDMap< TAnimal * > * m_VoleMap
 
int m_geneticproductfertilityeffect
 
- Public Attributes inherited from Population_Manager
int IndexArrayX [5][10000]
 
probe_dataTheProbe [100]
 
int SimH
 
int SimW
 
unsigned SimHH
 
unsigned SimWH
 
char m_SimulationName [255]
 
bool ProbesSet
 
Landscapem_TheLandscape
 

Protected Member Functions

void DoFirst ()
 
virtual void Catastrophe ()
 
bool OpenSexRatiosProbe ()
 
void CloseSexRatiosProbe ()
 
bool SuitableStartingLocation (int a_x, int a_y)
 
double AssessHabitat (int p_Polyref)
 Assess the quality of habitat at p_Polyref. More...
 
- Protected Member Functions inherited from Population_Manager
virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoBefore ()
 
virtual void DoAfter ()
 
virtual void DoAlmostLast ()
 
virtual void DoLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 

Protected Attributes

int thisYear
 
int YearsTotal
 
int m_GrowthStartDate
 
int m_male1
 
int m_female1
 
int m_total1
 
int m_male2
 
int m_female2
 
int m_total2
 
int m_male3
 
int m_female3
 
int m_total3
 
TrapLineMapm_Traplines
 
vector< double > VoleHabitatBaseQualities
 
ofstream * m_VoleAgeSexLocationFile
 
ofstream * m_VoleResistanceOutputFile
 
- Protected Attributes inherited from Population_Manager
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
AOR_Probem_AOR_Probe
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [32]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [12]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
ofstream * AOROutputPrb
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * ReallyBigOutputPrb
 
long int lamdagrid [2][257][257]
 

Detailed Description

The class to handle all vole population related matters.

Constructor & Destructor Documentation

◆ Vole_Population_Manager()

Vole_Population_Manager::Vole_Population_Manager ( Landscape p_L)

Class for managing lists of all voles in the simulation and responsible for generating output. Main functionality is the the base class Population_Manager

196  : Population_Manager(p_L)
197 {
198  // two lists are needed so need to remove 8 of the ten default arrays
199  // Males,Females
200  for (int i=0; i<6; i++)
201  {
202  TheArray.pop_back();
203  }
204  IDNumber=0;
205  thisYear=0;
206  YearsTotal=0;
207  m_VoleMap = new IDMap<TAnimal*>(p_L);
208  AFreq = new AlleleFreq();
209  m_GrowthStartDate=9000; // delays this until we know the real one
210  Init();
211 }
Class to handle statistics and constructs based on allele frequencies.
Definition: GeneticMaterial.h:62
Population_Manager(Landscape *L)
Definition: PopulationManager.cpp:221
vector< TListOfAnimals > TheArray
Definition: PopulationManager.h:534
unsigned IDNumber
Definition: VolePopulationManager.h:222
IDMap< TAnimal * > * m_VoleMap
Definition: VolePopulationManager.h:284
int thisYear
Definition: VolePopulationManager.h:155
int m_GrowthStartDate
Definition: VolePopulationManager.h:158
int YearsTotal
Definition: VolePopulationManager.h:155
virtual void Init(void)
Definition: VolePopulationManager.cpp:245
AlleleFreq * AFreq
Definition: VolePopulationManager.h:280

References AFreq, IDNumber, Init(), m_GrowthStartDate, m_VoleMap, Population_Manager::TheArray, thisYear, and YearsTotal.

◆ ~Vole_Population_Manager()

Vole_Population_Manager::~Vole_Population_Manager ( )
virtual

Vole_Population_Manager destructor
Only needed to close any potentially open output files

219 {
220  // Save the impacted file
221  //errno_t errNum;
222  // Output files for the vole
223  fclose( m_GeneticsFile );
224  fclose( m_AlleleFreqsFile );
225  fclose( m_EasyPopRes );
227  delete m_VoleMap;
228  delete AFreq;
229  // Vole traplines tidy-up
230  if (cfg_UseVoleTraplines.value()) {
231  delete m_Traplines;
232  }
233  if (cfg_RecordVoleMort.value()) {
235  delete m_VoleRecordMort;
236  }
238  {
239  (*m_VoleAgeSexLocationFile).close();
240  }
242 }
static CfgBool cfg_VoleUseResistanceOuput("VOLE_RESISTANCEOUTPUT_ON_OFF", CFG_CUSTOM, false)
static CfgBool cfg_UseVoleTraplines("VOLE_TRAPLINES_ON_OFF", CFG_CUSTOM, false)
CfgBool cfg_RecordVoleMort("VOLE_RECORDMORT_ON", CFG_CUSTOM, false)
static CfgBool cfg_useagesexlocation("VOLE_USEAGESEXLOCATION", CFG_CUSTOM, false)
CfgBool cfg_SexRatiosOutput_used("VOLE_SEXRATIOSOUTPUT_USED", CFG_CUSTOM, false)
bool value(void)
Definition: configurator.h:135
FILE * m_AlleleFreqsFile
Definition: PopulationManager.h:528
FILE * m_EasyPopRes
Definition: PopulationManager.h:529
FILE * m_GeneticsFile
Definition: PopulationManager.h:527
VoleSummaryOutput * m_VoleRecordMort
Definition: VolePopulationManager.h:197
void CloseResistanceOutput()
Closes the output file ready for resistance results.
Definition: VolePopulationManager.cpp:4224
TrapLineMap * m_Traplines
Definition: VolePopulationManager.h:171
void CloseSexRatiosProbe()
Definition: VolePopulationManager.cpp:3905
virtual void OPrint()
Definition: VolePopulationManager.cpp:4011

References AFreq, cfg_RecordVoleMort, cfg_SexRatiosOutput_used, cfg_useagesexlocation, cfg_UseVoleTraplines, cfg_VoleUseResistanceOuput, CloseResistanceOutput(), CloseSexRatiosProbe(), Population_Manager::m_AlleleFreqsFile, Population_Manager::m_EasyPopRes, Population_Manager::m_GeneticsFile, m_Traplines, m_VoleMap, m_VoleRecordMort, VoleSummaryOutput::OPrint(), and CfgBool::value().

Member Function Documentation

◆ AddToFrag1Female()

void Vole_Population_Manager::AddToFrag1Female ( )
inline
216 {m_female1++;}
int m_female1
Definition: VolePopulationManager.h:160

References m_female1.

◆ AddToFrag1Male()

void Vole_Population_Manager::AddToFrag1Male ( )
inline
215 {m_male1++;} // ***TD***
int m_male1
Definition: VolePopulationManager.h:159

References m_male1.

◆ AddToFrag2Female()

void Vole_Population_Manager::AddToFrag2Female ( )
inline
218 {m_female2++;}
int m_female2
Definition: VolePopulationManager.h:164

References m_female2.

◆ AddToFrag2Male()

void Vole_Population_Manager::AddToFrag2Male ( )
inline
217 {m_male2++;}
int m_male2
Definition: VolePopulationManager.h:163

References m_male2.

◆ AddToFrag3Female()

void Vole_Population_Manager::AddToFrag3Female ( )
inline
220 {m_female3++;}
int m_female3
Definition: VolePopulationManager.h:168

References m_female3.

◆ AddToFrag3Male()

void Vole_Population_Manager::AddToFrag3Male ( )
inline
219 {m_male3++;}
int m_male3
Definition: VolePopulationManager.h:167

References m_male3.

◆ AddToJuvs()

void Vole_Population_Manager::AddToJuvs ( int  juvs)
inline
255 {JuvsProducedToday+=juvs;}
int JuvsProducedToday
Definition: VolePopulationManager.h:281

References JuvsProducedToday.

Referenced by Vole_Female::st_Lactating().

◆ AddToNoYoungInfanticideCount()

void Vole_Population_Manager::AddToNoYoungInfanticideCount ( int  m_NoOfYoung,
int  m_YoungAge 
)
inline
256  { // ***TD***
257  NoYoungKilledToday+=m_NoOfYoung;
258  if (m_YoungAge<5) {
259  NoYoungKilledToday4+=m_NoOfYoung;
260  }
261  else if (m_YoungAge<9){
262  NoYoungKilledToday8+=m_NoOfYoung;
263  }
264  else {NoYoungKilledToday9+=m_NoOfYoung; }
265  }
int NoYoungKilledToday8
Definition: VolePopulationManager.h:282
int NoYoungKilledToday
Definition: VolePopulationManager.h:282
int NoYoungKilledToday4
Definition: VolePopulationManager.h:282
int NoYoungKilledToday9
Definition: VolePopulationManager.h:282

References NoYoungKilledToday, NoYoungKilledToday4, NoYoungKilledToday8, and NoYoungKilledToday9.

Referenced by Vole_Female::OnInfanticideAttempt().

◆ AddToYoung()

void Vole_Population_Manager::AddToYoung ( int  young)
inline
250 {YoungProducedToday+=young;}
int YoungProducedToday
Definition: VolePopulationManager.h:281

References YoungProducedToday.

Referenced by Vole_Female::st_GiveBirth().

◆ AddToYoungYr()

void Vole_Population_Manager::AddToYoungYr ( int  young)
inline
254 {YoungProducedToday+=young;}

References YoungProducedToday.

◆ AssessHabitat()

double Vole_Population_Manager::AssessHabitat ( int  p_Polyref)
protected

Assess the quality of habitat at p_Polyref.

Each unit of area (1m2) is assigned a score based on the polygon type. These scores fall currently into a limited number of catagories, with 4, 3, 2.5, 2, 1, & 0 being the only scores currently used. 2.5 is only used by young forest which is a hybrid between 2 & 3 represented by grassland and forest respectively. 4 denotes the best possible conditions.
Once the score has been obtained it is modified by the digestability of the vegetation in terms of proportion of young green matter. This modifies the value by multiplication with 0.7-1.0

772 {
780  TTypesOfLandscapeElement ElementType;
781  ElementType = m_TheLandscape->SupplyElementTypeFromVector(p_Polyref);
782  TTypesOfVegetation VType;
783  double Cover;
784  //double digestability = ( m_TheLandscape->SupplyVegDigestabilityVector(p_Polyref) + 0.2 );
785  //double digestability = ( m_TheLandscape->SupplyVegDigestabilityVector(p_Polyref)+0.1) * (1.0/0.9);
786  double digestability = 1.0;
787  double score = -9999;
788  switch (ElementType)
789  {
790  case tole_Railway: // 118
791  case tole_FieldBoundary: // 160
792  case tole_RoadsideVerge: // 13
793  case tole_RoadsideSlope:
794  case tole_HedgeBank:
795  case tole_Hedges: // 130 (internal ALMaSS representation for Hedges)
796  case tole_BeetleBank:
798  case tole_NaturalGrassDry: // 110
799  if (m_TheLandscape->SupplyVegHeightVector(p_Polyref) <= 5.0) score = 2.25;
800  else score = 3.0;
801  break;
802  case tole_PermPasture: // 35
803  if (m_TheLandscape->SupplyGrazingPressureVector(p_Polyref) > 0) score = 2.0; else score = 2.7;
804  break;
806  if (m_TheLandscape->SupplyGrazingPressureVector(p_Polyref) > 0) score = 2.1; else score = 2.8;
807  break;
809  if (m_TheLandscape->SupplyGrazingPressureVector(p_Polyref) > 0) score = 2.25; else score = 3.0;
810  break;
811  case tole_Orchard: // 56
812  // Quality depends on when it was mown
813  {
814  if (m_TheLandscape->SupplyVegCoverVector(p_Polyref) < 0.8) score = 2.5;
815  else if (m_TheLandscape->SupplyVegHeightVector(p_Polyref) <= 40) score = 2.5;
816  else score = 3.0;
817  }
818  if (m_TheLandscape->SupplyJustMownVector(p_Polyref)) score -= 2.0;
819  break;
820  case tole_MownGrass: // 58
821  // Quality depends on when it was mown
822  if (m_TheLandscape->SupplyJustMownVector(p_Polyref)) score = 2.5; else score = 3.0;
823  break;
824  case tole_OrchardBand: // 57
825  // If spraying herbicide then quality depends on time since spraying. SupplyJustSprayed returns a counter that counts down to zero after spraying.
826  // score = 3.0 - (0.5*m_TheLandscape->SupplyJustSprayedVector(p_Polyref)); // For herbicide
827  score = 3.0;
828  break;
830  case tole_YoungForest: // 60
831  score = 2.2;
832  break;
833  case tole_Marsh: // 95
834  case tole_Scrub: // 70
835  case tole_Heath:
836  case tole_RiversidePlants: // 98
837  case tole_PitDisused: // 75
838  case tole_UnknownGrass:
839  case tole_Wasteland:
840  score = 1.5;
841  break;
842  case tole_MixedForest: // 60
843  case tole_DeciduousForest: // 40
844  case tole_RiversideTrees: // 97
845  case tole_ConiferousForest: // 50
847  case tole_Parkland:
848  case tole_Copse:
849  case tole_AmenityGrass:
850  case tole_MetalledPath: //202
851  case tole_WoodyEnergyCrop:// 59
852  case tole_WoodlandMargin:
853  case tole_IndividualTree:
854  score = 1;
855  break;
856  case tole_Garden: //11
857  case tole_Track: // 123
858  case tole_SmallRoad: // 122
859  case tole_LargeRoad: // 121
860  case tole_BareRock:
861  case tole_UrbanNoVeg:
862  case tole_UrbanPark:
863  case tole_SandDune:
864  case tole_Churchyard:
865  case tole_HeritageSite:
866  case tole_Saltmarsh:
867  case tole_PlantNursery:
868  case tole_WindTurbine:
869  case tole_Pylon:
870  score = 0;
871  break;
872  case tole_Building: // 5
873  case tole_Carpark:
874  case tole_ActivePit: // 115
875  case tole_Freshwater: // 90
876  case tole_Pond:
877  case tole_Stream:
878  case tole_Saltwater: // 80
879  case tole_Coast: // 100
880  case tole_StoneWall: // 15
881  case tole_Fence: //225
882  case tole_River:
883  score = -1;
884  break;
885  case tole_Field: // 20 & 30
887  VType = m_TheLandscape->SupplyVegTypeVector(p_Polyref);
888  Cover = m_TheLandscape->SupplyVegCoverVector(p_Polyref);
889  if (Cover < 0.20) score = 0;
890  else switch (VType)
891  {
892  case tov_SeedGrass1:
893  case tov_SeedGrass2:
894  score = 2.25;
895  break;
896  case tov_BroadBeans:
897  case tov_FieldPeas:
898  case tov_FieldPeasSilage:
899  case tov_WinterBarley:
900  case tov_OWinterBarley:
901  case tov_WinterRye:
902  case tov_OWinterRye:
903  case tov_Oats:
905  case tov_WinterWheat:
909  case tov_Triticale:
910  case tov_OTriticale:
912  case tov_WWheatPControl:
915  case tov_WinterRape:
916  case tov_SpringRape:
917  case tov_OSpringBarley:
918  case tov_SpringBarley:
919  case tov_SpringBarleySpr:
930  case tov_OSBarleySilage:
932  case tov_OWinterWheat:
933  case tov_OFieldPeas:
936  case tov_OWinterRape:
937  case tov_Maize:
938  case tov_MaizeSilage:
939  case tov_OMaizeSilage:
940  case tov_OOats:
941  score = 1;
942  break;
943  case tov_OGrazingPigs:
944  case tov_FodderBeet:
945  case tov_SugarBeet:
946  case tov_OFodderBeet:
947  case tov_Carrots:
948  case tov_OCarrots:
949  case tov_Potatoes:
951  case tov_NoGrowth:
952  score = 0;
953  break;
954  // Needs some more thought
956  case tov_FodderGrass:
961  case tov_OSeedGrass1:
962  case tov_OSeedGrass2:
963  if (m_TheLandscape->SupplyGrazingPressureVector(p_Polyref) > 0) score = 1;
964  else score = 2;
965  break;
969  if (m_TheLandscape->SupplyGrazingPressureVector(p_Polyref) > 0) score = 2.2;
970  else score = 2.6;
971  break;
973  if (m_TheLandscape->SupplyGrazingPressureVector(p_Polyref) > 0) score = 2.25;
974  else score = 3.0;
975  break;
977  case tov_OSetaside:
978  case tov_Setaside:
979  score = 3.0;
980  break;
981  case tov_OrchardCrop:
982  case tov_YoungForest:
983  // Quality depends on when it was mown
984  if (m_TheLandscape->SupplyVegCoverVector(p_Polyref) < 0.8) score = 2.5;
985  else if (m_TheLandscape->SupplyVegHeightVector(p_Polyref) <= 40) score = 2.5;
986  else score = 3.0;
987  break;
988  default:
989  // Unknown vegetation type
990  m_TheLandscape->Warn("Vole_Population_Manager::AssessHabitat - Unknown vegt type", NULL);
991  exit(1);
992  break;
993  }
994  break;
995  case tole_Foobar: // 999 !! type unknown - should not happen
996  default:
997  static char errornum[20];
998  sprintf(errornum, "%d", ElementType);
999  m_TheLandscape->Warn("Vole_PopulationManager:AssessHabitat: Unknown tole_type",
1000  errornum);
1001  exit(1);
1002  }
1003  return (score*digestability);
1004 }
double SupplyVegHeightVector(unsigned int a_index)
Definition: landscape.h:931
int SupplyGrazingPressureVector(unsigned int a_index)
Definition: landscape.h:1232
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
Definition: landscape.h:1104
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
bool SupplyJustMownVector(unsigned int a_index)
Definition: landscape.h:1258
TTypesOfVegetation SupplyVegTypeVector(unsigned int a_index)
Definition: landscape.h:1220
double SupplyVegCoverVector(unsigned int a_index)
Definition: landscape.h:1053
Landscape * m_TheLandscape
Definition: PopulationManager.h:515
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_BareRock
Definition: tole_declaration.h:75
@ tole_PermPastureTussocky
Definition: tole_declaration.h:45
@ tole_Saltmarsh
Definition: tole_declaration.h:88
@ tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
@ tole_Carpark
Definition: tole_declaration.h:85
@ tole_Coast
Definition: tole_declaration.h:67
@ tole_UrbanNoVeg
Definition: tole_declaration.h:78
@ tole_Stream
Definition: tole_declaration.h:89
@ tole_Saltwater
Definition: tole_declaration.h:66
@ tole_MixedForest
Definition: tole_declaration.h:53
@ tole_HeritageSite
Definition: tole_declaration.h:90
@ tole_WoodlandMargin
Definition: tole_declaration.h:98
@ tole_RoadsideSlope
Definition: tole_declaration.h:83
@ tole_River
Definition: tole_declaration.h:65
@ tole_StoneWall
Definition: tole_declaration.h:56
@ tole_Parkland
Definition: tole_declaration.h:77
@ tole_NaturalGrassWet
Definition: tole_declaration.h:87
@ tole_NaturalGrassDry
Definition: tole_declaration.h:48
@ tole_UrbanPark
Definition: tole_declaration.h:79
@ tole_Pylon
Definition: tole_declaration.h:96
@ tole_PermanentSetaside
Definition: tole_declaration.h:46
@ tole_Garden
Definition: tole_declaration.h:58
@ tole_Pond
Definition: tole_declaration.h:101
@ tole_Scrub
Definition: tole_declaration.h:42
@ tole_Fence
Definition: tole_declaration.h:57
@ tole_Field
Definition: tole_declaration.h:43
@ tole_Copse
Definition: tole_declaration.h:82
@ tole_PermPasture
Definition: tole_declaration.h:47
@ tole_Hedges
Definition: tole_declaration.h:37
@ tole_Track
Definition: tole_declaration.h:59
@ tole_Heath
Definition: tole_declaration.h:70
@ tole_Freshwater
Definition: tole_declaration.h:64
@ tole_PitDisused
Definition: tole_declaration.h:50
@ tole_FieldBoundary
Definition: tole_declaration.h:40
@ tole_PlantNursery
Definition: tole_declaration.h:95
@ tole_DeciduousForest
Definition: tole_declaration.h:52
@ tole_ActivePit
Definition: tole_declaration.h:63
@ tole_RiversidePlants
Definition: tole_declaration.h:49
@ tole_Building
Definition: tole_declaration.h:62
@ tole_RoadsideVerge
Definition: tole_declaration.h:38
@ tole_Orchard
Definition: tole_declaration.h:71
@ tole_MownGrass
Definition: tole_declaration.h:74
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_OrchardBand
Definition: tole_declaration.h:73
@ tole_SmallRoad
Definition: tole_declaration.h:60
@ tole_Churchyard
Definition: tole_declaration.h:86
@ tole_BuiltUpWithParkland
Definition: tole_declaration.h:80
@ tole_AmenityGrass
Definition: tole_declaration.h:76
@ tole_PermPastureLowYield
Definition: tole_declaration.h:44
@ tole_HedgeBank
Definition: tole_declaration.h:68
@ tole_Railway
Definition: tole_declaration.h:39
@ tole_WindTurbine
Definition: tole_declaration.h:97
@ tole_ConiferousForest
Definition: tole_declaration.h:54
@ tole_SandDune
Definition: tole_declaration.h:81
@ tole_Wasteland
Definition: tole_declaration.h:92
@ tole_IndividualTree
Definition: tole_declaration.h:93
@ tole_UnknownGrass
Definition: tole_declaration.h:91
@ tole_Foobar
Definition: tole_declaration.h:111
@ tole_RiversideTrees
Definition: tole_declaration.h:51
@ tole_LargeRoad
Definition: tole_declaration.h:61
@ tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
@ tole_BeetleBank
Definition: tole_declaration.h:69
@ tole_MetalledPath
Definition: tole_declaration.h:84
@ tole_Marsh
Definition: tole_declaration.h:41
TTypesOfVegetation
Definition: tov_declaration.h:30
@ tov_WWheatPControl
Definition: tov_declaration.h:55
@ tov_OWinterWheatUndersown
Definition: tov_declaration.h:49
@ tov_BroadBeans
Definition: tov_declaration.h:66
@ tov_PermanentGrassGrazed
Definition: tov_declaration.h:49
@ tov_SpringBarleySKManagement
Definition: tov_declaration.h:65
@ tov_OFieldPeas
Definition: tov_declaration.h:43
@ tov_SpringBarleyPTreatment
Definition: tov_declaration.h:63
@ tov_SpringBarleyPeaCloverGrassStrigling
Definition: tov_declaration.h:60
@ tov_OSpringBarleyPigs
Definition: tov_declaration.h:47
@ tov_WWheatPTreatment
Definition: tov_declaration.h:55
@ tov_PermanentSetaside
Definition: tov_declaration.h:49
@ tov_WinterWheatStriglingCulm
Definition: tov_declaration.h:62
@ tov_FodderGrass
Definition: tov_declaration.h:62
@ tov_SeedGrass1
Definition: tov_declaration.h:50
@ tov_OGrazingPigs
Definition: tov_declaration.h:44
@ tov_NoGrowth
Definition: tov_declaration.h:38
@ tov_CloverGrassGrazed2
Definition: tov_declaration.h:33
@ tov_OSpringBarley
Definition: tov_declaration.h:46
@ tov_PotatoesIndustry
Definition: tov_declaration.h:50
@ tov_PermanentGrassTussocky
Definition: tov_declaration.h:49
@ tov_FieldPeasSilage
Definition: tov_declaration.h:65
@ tov_OWinterRape
Definition: tov_declaration.h:47
@ tov_WinterRape
Definition: tov_declaration.h:53
@ tov_OPermanentGrassGrazed
Definition: tov_declaration.h:44
@ tov_SpringBarley
Definition: tov_declaration.h:52
@ tov_OWinterBarley
Definition: tov_declaration.h:47
@ tov_SpringBarleyStriglingSingle
Definition: tov_declaration.h:60
@ tov_OSeedGrass1
Definition: tov_declaration.h:46
@ tov_SpringBarleySilage
Definition: tov_declaration.h:52
@ tov_SpringBarleySeed
Definition: tov_declaration.h:52
@ tov_SpringBarleyCloverGrass
Definition: tov_declaration.h:52
@ tov_Carrots
Definition: tov_declaration.h:31
@ tov_FieldPeas
Definition: tov_declaration.h:34
@ tov_WWheatPToxicControl
Definition: tov_declaration.h:55
@ tov_OTriticale
Definition: tov_declaration.h:47
@ tov_OMaizeSilage
Definition: tov_declaration.h:65
@ tov_Triticale
Definition: tov_declaration.h:53
@ tov_OFodderBeet
Definition: tov_declaration.h:65
@ tov_WinterWheat
Definition: tov_declaration.h:55
@ tov_OCarrots
Definition: tov_declaration.h:43
@ tov_OSBarleySilage
Definition: tov_declaration.h:56
@ tov_WinterWheatStrigling
Definition: tov_declaration.h:59
@ tov_SeedGrass2
Definition: tov_declaration.h:50
@ tov_OFieldPeasSilage
Definition: tov_declaration.h:56
@ tov_SugarBeet
Definition: tov_declaration.h:66
@ tov_PermanentGrassLowYield
Definition: tov_declaration.h:63
@ tov_CloverGrassGrazed1
Definition: tov_declaration.h:32
@ tov_SpringRape
Definition: tov_declaration.h:53
@ tov_SpringBarleySpr
Definition: tov_declaration.h:66
@ tov_OSeedGrass2
Definition: tov_declaration.h:46
@ tov_Oats
Definition: tov_declaration.h:40
@ tov_MaizeSilage
Definition: tov_declaration.h:62
@ tov_OBarleyPeaCloverGrass
Definition: tov_declaration.h:41
@ tov_SpringBarleyStriglingCulm
Definition: tov_declaration.h:62
@ tov_Maize
Definition: tov_declaration.h:36
@ tov_OCloverGrassSilage1
Definition: tov_declaration.h:43
@ tov_OCloverGrassGrazed2
Definition: tov_declaration.h:43
@ tov_Potatoes
Definition: tov_declaration.h:50
@ tov_Setaside
Definition: tov_declaration.h:50
@ tov_OWinterWheat
Definition: tov_declaration.h:66
@ tov_OWinterRye
Definition: tov_declaration.h:49
@ tov_OOats
Definition: tov_declaration.h:44
@ tov_OCloverGrassGrazed1
Definition: tov_declaration.h:43
@ tov_WinterRye
Definition: tov_declaration.h:55
@ tov_FodderBeet
Definition: tov_declaration.h:35
@ tov_WinterWheatStriglingSingle
Definition: tov_declaration.h:62
@ tov_WinterBarley
Definition: tov_declaration.h:53
@ tov_SpringBarleyStrigling
Definition: tov_declaration.h:58
@ tov_WinterWheatShort
Definition: tov_declaration.h:56
@ tov_YoungForest
Definition: tov_declaration.h:60
@ tov_AgroChemIndustryCereal
Definition: tov_declaration.h:55
@ tov_OrchardCrop
Definition: tov_declaration.h:65
@ tov_OSetaside
Definition: tov_declaration.h:46

References Population_Manager::m_TheLandscape, Landscape::SupplyElementTypeFromVector(), Landscape::SupplyGrazingPressureVector(), Landscape::SupplyJustMownVector(), Landscape::SupplyVegCoverVector(), Landscape::SupplyVegHeightVector(), Landscape::SupplyVegTypeVector(), tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Fence, tole_Field, tole_FieldBoundary, tole_Foobar, tole_Freshwater, tole_Garden, tole_Heath, tole_HedgeBank, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnknownGrass, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_Wasteland, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_FieldPeas, tov_FieldPeasSilage, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_NoGrowth, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OCarrots, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OCloverGrassSilage1, tov_OFieldPeas, tov_OFieldPeasSilage, tov_OFodderBeet, tov_OGrazingPigs, tov_OMaizeSilage, tov_OOats, tov_OPermanentGrassGrazed, tov_OrchardCrop, tov_OSBarleySilage, tov_OSeedGrass1, tov_OSeedGrass2, tov_OSetaside, tov_OSpringBarley, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterRape, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_Potatoes, tov_PotatoesIndustry, tov_SeedGrass1, tov_SeedGrass2, tov_Setaside, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyPeaCloverGrassStrigling, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySilage, tov_SpringBarleySKManagement, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringRape, tov_SugarBeet, tov_Triticale, tov_WinterBarley, tov_WinterRape, tov_WinterRye, tov_WinterWheat, tov_WinterWheatShort, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, tov_WWheatPTreatment, tov_YoungForest, and Landscape::Warn().

Referenced by DoFirst().

◆ BarrierSearch()

bool Vole_Population_Manager::BarrierSearch ( int  F_x,
int  F_y,
int  M_x,
int  M_y 
)

Prevents voles from mating with an individual on the other side of af barrier

1262 {
1263  int poly2 = 200;
1264 
1265  if(F_x == M_x){
1266  if (F_y == M_y) return true; // if they are on the same spot
1267  if(F_y < M_y){ // if they have the same x coordinate and different y coordinates and the female has the lowest y
1268  for (int j = F_y; j < M_y; j++){
1269  int poly1 = m_TheLandscape->SupplyPolyRef(F_x, j);
1270  if (poly2 != poly1){
1271  poly2 = poly1;
1272  int Elem = m_TheLandscape->SupplyElementType(poly1);
1273 
1274  switch (Elem){
1275  case tole_MetalledPath:
1276  case tole_Carpark:
1277  case tole_Churchyard:
1278  case tole_Saltmarsh:
1279  case tole_Stream:
1280  case tole_HeritageSite:
1281  case tole_Freshwater:
1282  case tole_Pond:
1283  case tole_River:
1284  case tole_Saltwater:
1285  case tole_LargeRoad:
1286  case tole_Building:
1287  case tole_Coast:
1288  case tole_DeciduousForest:
1289  case tole_ConiferousForest:
1290  return false;
1291  default:
1292  break;
1293  }
1294  }
1295  }
1296  return true;
1297  }
1298  else { // if (F_y > M_y) if they have the same x coordinate and different y coordinates and the male has the lowest y
1299  for (int j = M_y; j < F_y; j++){
1300  int poly1 = m_TheLandscape->SupplyPolyRef(M_x, j);
1301  if (poly1 != poly2){
1302  poly2 = poly1;
1303  int Elem = m_TheLandscape->SupplyElementType(poly1);
1304 
1305  switch (Elem){
1306  case tole_MetalledPath:
1307  case tole_Carpark:
1308  case tole_Churchyard:
1309  case tole_Saltmarsh:
1310  case tole_Stream:
1311  case tole_HeritageSite:
1312  case tole_Freshwater:
1313  case tole_Pond:
1314  case tole_River:
1315  case tole_Saltwater:
1316  case tole_LargeRoad:
1317  case tole_Building:
1318  case tole_Coast:
1319  case tole_DeciduousForest:
1320  case tole_ConiferousForest:
1321  return false;
1322  default:
1323  break;
1324  }
1325  }
1326  }
1327  return true;
1328  }
1329  }
1330  if (F_y == M_y){
1331  if (F_x < M_x) { // if they have the same y coordinate and different x coordinates and the female's x coordinate is the lowest
1332  for (int i = F_x; i < M_x; i++){
1333  int poly1 = m_TheLandscape->SupplyPolyRef(i, F_y);
1334  if (poly1 != poly2){
1335  poly2 = poly1;
1336  int Elem = m_TheLandscape->SupplyElementType(poly1);
1337 
1338  switch (Elem){
1339  case tole_MetalledPath:
1340  case tole_Carpark:
1341  case tole_Churchyard:
1342  case tole_Saltmarsh:
1343  case tole_Stream:
1344  case tole_HeritageSite:
1345  case tole_Freshwater:
1346  case tole_Pond:
1347  case tole_River:
1348  case tole_Saltwater:
1349  case tole_LargeRoad:
1350  case tole_Building:
1351  case tole_Coast:
1352  case tole_DeciduousForest:
1353  case tole_ConiferousForest:
1354  return false;
1355  default:
1356  break;
1357  }
1358  }
1359  }
1360  return true;
1361  }
1362  else { // (F_x > M_x) if they have the same y coordinate and different x coordinates and the male's x coordinate is the lowest
1363  for (int i = M_x; i < F_x; i++){
1364  int poly1 = m_TheLandscape->SupplyPolyRef(i, M_y);
1365  if (poly1 != poly2){
1366  poly2 = poly1;
1367  int Elem = m_TheLandscape->SupplyElementType(poly1);
1368 
1369  switch (Elem){
1370  case tole_MetalledPath:
1371  case tole_Carpark:
1372  case tole_Churchyard:
1373  case tole_Saltmarsh:
1374  case tole_Stream:
1375  case tole_HeritageSite:
1376  case tole_Pond:
1377  case tole_Freshwater:
1378  case tole_River:
1379  case tole_Saltwater:
1380  case tole_LargeRoad:
1381  case tole_Building:
1382  case tole_Coast:
1383  case tole_DeciduousForest:
1384  case tole_ConiferousForest:
1385  return false;
1386  default:
1387  break;
1388  }
1389  }
1390  }
1391  return true;
1392  }
1393  }
1394  if (F_x < M_x){ // if the x coordinates differ and the females is the lowest
1395  if (F_y < M_y){ // if the y coordinates differ and the female has the lowest y coordinate
1396  unsigned diff_x = M_x - F_x;
1397  unsigned diff_y = M_y - F_y;
1398  if (diff_x <= diff_y){ // if the area between them is enlongated (y) or diagonal
1399  int j = F_y;
1400 
1401  for (int i = F_x; i < M_x; i++){ // the diagonal part
1402  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1403  j++;
1404  if (poly1 != poly2){
1405  poly2 = poly1;
1406  int Elem = m_TheLandscape->SupplyElementType(poly1);
1407 
1408  switch (Elem){
1409  case tole_MetalledPath:
1410  case tole_Carpark:
1411  case tole_Churchyard:
1412  case tole_Saltmarsh:
1413  case tole_Stream:
1414  case tole_HeritageSite:
1415  case tole_Pond:
1416  case tole_Freshwater:
1417  case tole_River:
1418  case tole_Saltwater:
1419  case tole_LargeRoad:
1420  case tole_Building:
1421  case tole_Coast:
1422  case tole_DeciduousForest:
1423  case tole_ConiferousForest:
1424  return false;
1425  default:
1426  break;
1427  }
1428  }
1429  }
1430  if (diff_x != diff_y){ // if not diagonal but enlongated and the x and y coordinates differ with the female having the lowest values
1431  int j_extent = F_y + diff_x;
1432  for (int j_y = j_extent; j_y < M_y; j_y++){ // the enlongated part
1433  int poly1 = m_TheLandscape->SupplyPolyRef(M_x, j_y);
1434  if (poly1 != poly2){
1435  poly2 = poly1;
1436  int Elem = m_TheLandscape->SupplyElementType(poly1);
1437 
1438  switch (Elem){
1439  case tole_MetalledPath:
1440  case tole_Carpark:
1441  case tole_Churchyard:
1442  case tole_Saltmarsh:
1443  case tole_Stream:
1444  case tole_HeritageSite:
1445  case tole_Pond:
1446  case tole_Freshwater:
1447  case tole_River:
1448  case tole_Saltwater:
1449  case tole_LargeRoad:
1450  case tole_Building:
1451  case tole_Coast:
1452  case tole_DeciduousForest:
1453  case tole_ConiferousForest:
1454  return false;
1455  default:
1456  break;
1457  }
1458  }
1459  }
1460  }
1461  return true;
1462  }
1463  if (diff_x > diff_y) { // if not diagonal but widened and the x and y coordinates differ with the female having the lowest values
1464  int i = F_x;
1465  for (int j = F_y; j < M_y; j++){ // the diagonal part
1466  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1467  i++;
1468  if (poly1 != poly2){
1469  poly2 = poly1;
1470  int Elem = m_TheLandscape->SupplyElementType(poly1);
1471 
1472  switch (Elem){
1473  case tole_MetalledPath:
1474  case tole_Carpark:
1475  case tole_Churchyard:
1476  case tole_Saltmarsh:
1477  case tole_Stream:
1478  case tole_HeritageSite:
1479  case tole_Pond:
1480  case tole_Freshwater:
1481  case tole_River:
1482  case tole_Saltwater:
1483  case tole_LargeRoad:
1484  case tole_Building:
1485  case tole_Coast:
1486  case tole_DeciduousForest:
1487  case tole_ConiferousForest:
1488  return false;
1489  default:
1490  break;
1491  }
1492  }
1493  }
1494  int i_extent = diff_y + F_x;
1495  for (int i_x = i_extent; i_x < M_x; i_x++){ // the widened part
1496  int poly1 = m_TheLandscape->SupplyPolyRef(i_x, M_y);
1497  if (poly1 != poly2){
1498  poly2 = poly1;
1499  int Elem = m_TheLandscape->SupplyElementType(poly1);
1500 
1501  switch (Elem){
1502  case tole_MetalledPath:
1503  case tole_Carpark:
1504  case tole_Churchyard:
1505  case tole_Saltmarsh:
1506  case tole_Stream:
1507  case tole_HeritageSite:
1508  case tole_Pond:
1509  case tole_Freshwater:
1510  case tole_River:
1511  case tole_Saltwater:
1512  case tole_LargeRoad:
1513  case tole_Building:
1514  case tole_Coast:
1515  case tole_DeciduousForest:
1516  case tole_ConiferousForest:
1517  return false;
1518  default:
1519  break;
1520  }
1521  }
1522  }
1523  return true;
1524  }
1525  }
1526  if (F_y > M_y) { // and if (F_x < M_x)
1527  int diff_x = M_x - F_x;
1528  int diff_y = F_y - M_y;
1529  if (diff_x <= diff_y){ // if the area between them is enlongated (y) or diagonal
1530  int j = F_y;
1531  for (int i = F_x; i < M_x; i++){ // the diagonal part
1532  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1533  j--;
1534  if (poly1 != poly2){
1535  poly2 = poly1;
1536  int Elem = m_TheLandscape->SupplyElementType(poly1);
1537 
1538  switch (Elem){
1539  case tole_MetalledPath:
1540  case tole_Carpark:
1541  case tole_Churchyard:
1542  case tole_Saltmarsh:
1543  case tole_Stream:
1544  case tole_HeritageSite:
1545  case tole_Pond:
1546  case tole_Freshwater:
1547  case tole_River:
1548  case tole_Saltwater:
1549  case tole_LargeRoad:
1550  case tole_Building:
1551  case tole_Coast:
1552  case tole_DeciduousForest:
1553  case tole_ConiferousForest:
1554  return false;
1555  default:
1556  break;
1557  }
1558  }
1559  }
1560  if (diff_x != diff_y){ // if not diagonal but enlongated and the x and y coordinates differ with the female having the lowest x value and highest y
1561  int j_extent = F_y - diff_x;
1562  for (int j_y = j_extent; j_y > M_y; j_y--){ // the enlongated part
1563  int poly1 = m_TheLandscape->SupplyPolyRef(M_x, j_y);
1564  if (poly1 != poly2){
1565  poly2 = poly1;
1566  int Elem = m_TheLandscape->SupplyElementType(poly1);
1567 
1568  switch (Elem){
1569  case tole_MetalledPath:
1570  case tole_Carpark:
1571  case tole_Churchyard:
1572  case tole_Saltmarsh:
1573  case tole_Stream:
1574  case tole_HeritageSite:
1575  case tole_Pond:
1576  case tole_Freshwater:
1577  case tole_River:
1578  case tole_Saltwater:
1579  case tole_LargeRoad:
1580  case tole_Building:
1581  case tole_Coast:
1582  case tole_DeciduousForest:
1583  case tole_ConiferousForest:
1584  return false;
1585  default:
1586  break;
1587  }
1588  }
1589  }
1590  }
1591  return true;
1592  }
1593  else { // if (diff_x > diff_y) if not diagonal but widened and the x and y coordinates differ with the female having the lowest x and highest y
1594  int i = F_x;
1595  for (int j = F_y; j > M_y; j--){ // the diagonal part
1596  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1597  i++;
1598  if (poly1 != poly2){
1599  poly2 = poly1;
1600  int Elem = m_TheLandscape->SupplyElementType(poly1);
1601 
1602  switch (Elem){
1603  case tole_MetalledPath:
1604  case tole_Carpark:
1605  case tole_Churchyard:
1606  case tole_Saltmarsh:
1607  case tole_Stream:
1608  case tole_HeritageSite:
1609  case tole_Pond:
1610  case tole_Freshwater:
1611  case tole_River:
1612  case tole_Saltwater:
1613  case tole_LargeRoad:
1614  case tole_Building:
1615  case tole_Coast:
1616  case tole_DeciduousForest:
1617  case tole_ConiferousForest:
1618  return false;
1619  default:
1620  break;
1621  }
1622  }
1623  }
1624  int i_extent = diff_y + F_x;
1625  for (int i_x = i_extent; i_x < M_x; i_x++){ // the widened part
1626  int poly1 = m_TheLandscape->SupplyPolyRef(i_x, M_y);
1627  if (poly1 != poly2){
1628  poly2 = poly1;
1629  int Elem = m_TheLandscape->SupplyElementType(poly1);
1630 
1631  switch (Elem){
1632  case tole_MetalledPath:
1633  case tole_Carpark:
1634  case tole_Churchyard:
1635  case tole_Saltmarsh:
1636  case tole_Stream:
1637  case tole_HeritageSite:
1638  case tole_Pond:
1639  case tole_Freshwater:
1640  case tole_River:
1641  case tole_Saltwater:
1642  case tole_LargeRoad:
1643  case tole_Building:
1644  case tole_Coast:
1645  case tole_DeciduousForest:
1646  case tole_ConiferousForest:
1647  return false;
1648  default:
1649  break;
1650  }
1651  }
1652  }
1653  return true;
1654  }
1655  }
1656  }
1657  if (F_x > M_x){
1658  if (F_y < M_y){
1659  unsigned diff_x = F_x - M_x;
1660  unsigned diff_y = M_y - F_y;
1661  if (diff_x <= diff_y){ // if the area between them is enlongated (y) or diagonal
1662  int j = M_y;
1663  for (int i = M_x; i < F_x; i++){ // the diagonal part
1664  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1665  j--;
1666  if (poly1 != poly2){
1667  poly2 = poly1;
1668  int Elem = m_TheLandscape->SupplyElementType(poly1);
1669 
1670  switch (Elem){
1671  case tole_MetalledPath:
1672  case tole_Carpark:
1673  case tole_Churchyard:
1674  case tole_Saltmarsh:
1675  case tole_Stream:
1676  case tole_HeritageSite:
1677  case tole_Pond:
1678  case tole_Freshwater:
1679  case tole_River:
1680  case tole_Saltwater:
1681  case tole_LargeRoad:
1682  case tole_Building:
1683  case tole_Coast:
1684  case tole_DeciduousForest:
1685  case tole_ConiferousForest:
1686  return false;
1687  default:
1688  break;
1689  }
1690  }
1691  }
1692 
1693  if (diff_x != diff_y){ // if not diagonal but enlongated and the x and y coordinates differ with the female having the lowest values
1694  int j_extent = M_y - diff_x;
1695  for (int j_y = j_extent; j_y > F_y; j_y--){ // the enlongated part
1696  int poly1 = m_TheLandscape->SupplyPolyRef(F_x, j_y);
1697  if (poly1 != poly2){
1698  poly2 = poly1;
1699  int Elem = m_TheLandscape->SupplyElementType(poly1);
1700 
1701  switch (Elem){
1702  case tole_MetalledPath:
1703  case tole_Carpark:
1704  case tole_Churchyard:
1705  case tole_Saltmarsh:
1706  case tole_Stream:
1707  case tole_HeritageSite:
1708  case tole_Pond:
1709  case tole_Freshwater:
1710  case tole_River:
1711  case tole_Saltwater:
1712  case tole_LargeRoad:
1713  case tole_Building:
1714  case tole_Coast:
1715  case tole_DeciduousForest:
1716  case tole_ConiferousForest:
1717  return false;
1718  default:
1719  break;
1720  }
1721  }
1722  }
1723  }
1724  return true;
1725  }
1726  else { // if (diff_x > diff_y) if not diagonal but widened and the x and y coordinates differ with the female having the lowest values
1727  int i = M_x;
1728  for (int j = M_y; j > F_y; j--){
1729  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1730  i++;
1731  if (poly1 != poly2){
1732  poly2 = poly1;
1733  int Elem = m_TheLandscape->SupplyElementType(poly1);
1734 
1735  switch (Elem){
1736  case tole_MetalledPath:
1737  case tole_Carpark:
1738  case tole_Churchyard:
1739  case tole_Saltmarsh:
1740  case tole_Stream:
1741  case tole_HeritageSite:
1742  case tole_Pond:
1743  case tole_Freshwater:
1744  case tole_River:
1745  case tole_Saltwater:
1746  case tole_LargeRoad:
1747  case tole_Building:
1748  case tole_Coast:
1749  case tole_DeciduousForest:
1750  case tole_ConiferousForest:
1751  return false;
1752  default:
1753  break;
1754  }
1755  }
1756  }
1757  int i_extent = diff_y + M_x;
1758  for (int i_x = i_extent; i_x < F_x; i_x++){ // the widened part
1759  int poly1 = m_TheLandscape->SupplyPolyRef(i_x, F_y);
1760  if (poly1 != poly2){
1761  poly2 = poly1;
1762  int Elem = m_TheLandscape->SupplyElementType(poly1);
1763 
1764  switch (Elem){
1765  case tole_MetalledPath:
1766  case tole_Carpark:
1767  case tole_Churchyard:
1768  case tole_Saltmarsh:
1769  case tole_Stream:
1770  case tole_HeritageSite:
1771  case tole_Pond:
1772  case tole_Freshwater:
1773  case tole_River:
1774  case tole_Saltwater:
1775  case tole_LargeRoad:
1776  case tole_Building:
1777  case tole_Coast:
1778  case tole_DeciduousForest:
1779  case tole_ConiferousForest:
1780  return false;
1781  default:
1782  break;
1783  }
1784  }
1785  }
1786  return true;
1787  }
1788  }
1789  if (F_y > M_y) {// if (F_x > M_x)
1790  int diff_x = F_x - M_x;
1791  int diff_y = F_y - M_y;
1792  if (diff_x <= diff_y){ // if the area between them is enlongated (y) or diagonal
1793  int j = M_y;
1794  for (int i = M_x; i < F_x; i++){ // the diagonal part
1795  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1796  j++;
1797  if (poly1 != poly2){
1798  poly2 = poly1;
1799  int Elem = m_TheLandscape->SupplyElementType(poly1);
1800 
1801  switch (Elem){
1802  case tole_MetalledPath:
1803  case tole_Carpark:
1804  case tole_Churchyard:
1805  case tole_Saltmarsh:
1806  case tole_Stream:
1807  case tole_HeritageSite:
1808  case tole_Pond:
1809  case tole_Freshwater:
1810  case tole_River:
1811  case tole_Saltwater:
1812  case tole_LargeRoad:
1813  case tole_Building:
1814  case tole_Coast:
1815  case tole_DeciduousForest:
1816  case tole_ConiferousForest:
1817  return false;
1818  default:
1819  break;
1820  }
1821  }
1822  }
1823  if (diff_x != diff_y){ // if not diagonal but enlongated and the x and y coordinates differ with the female having the lowest x value and highest y
1824  int j_extent = M_y + diff_x;
1825  for (int j_y = j_extent; j_y < F_y; j_y++){ // the enlongated part
1826  int poly1 = m_TheLandscape->SupplyPolyRef(F_x, j_y);
1827  if (poly1 != poly2){
1828  poly2 = poly1;
1829  int Elem = m_TheLandscape->SupplyElementType(poly1);
1830 
1831  switch (Elem){
1832  case tole_MetalledPath:
1833  case tole_Carpark:
1834  case tole_Churchyard:
1835  case tole_Saltmarsh:
1836  case tole_Stream:
1837  case tole_HeritageSite:
1838  case tole_Pond:
1839  case tole_Freshwater:
1840  case tole_River:
1841  case tole_Saltwater:
1842  case tole_LargeRoad:
1843  case tole_Building:
1844  case tole_Coast:
1845  case tole_DeciduousForest:
1846  case tole_ConiferousForest:
1847  return false;
1848  default:
1849  break;
1850  }
1851  }
1852  }
1853  }
1854  return true;
1855  }
1856  else { // if (diff_x > diff_y) if not diagonal but widened and the x and y coordinates differ with the female having the lowest x and highest y
1857  int i = M_x;
1858  for (int j = M_y; j < F_y; j++){ // the diagonal part
1859  int poly1 = m_TheLandscape->SupplyPolyRef(i, j);
1860  i++;
1861  if (poly1 != poly2){
1862  poly2 = poly1;
1863  int Elem = m_TheLandscape->SupplyElementType(poly1);
1864 
1865  switch (Elem){
1866  case tole_MetalledPath:
1867  case tole_Carpark:
1868  case tole_Churchyard:
1869  case tole_Saltmarsh:
1870  case tole_Stream:
1871  case tole_HeritageSite:
1872  case tole_Pond:
1873  case tole_Freshwater:
1874  case tole_River:
1875  case tole_Saltwater:
1876  case tole_LargeRoad:
1877  case tole_Building:
1878  case tole_Coast:
1879  case tole_DeciduousForest:
1880  case tole_ConiferousForest:
1881  return false;
1882  default:
1883  break;
1884  }
1885  }
1886  }
1887  int i_extent = diff_y + M_x;
1888  for (int i_x = i_extent; i_x < F_x; i_x++){ // the widened part
1889  int poly1 = m_TheLandscape->SupplyPolyRef(i_x, F_y);
1890  if (poly1 != poly2){
1891  poly2 = poly1;
1892  int Elem = m_TheLandscape->SupplyElementType(poly1);
1893 
1894  switch (Elem){
1895  case tole_MetalledPath:
1896  case tole_Carpark:
1897  case tole_Churchyard:
1898  case tole_Saltmarsh:
1899  case tole_Stream:
1900  case tole_HeritageSite:
1901  case tole_Pond:
1902  case tole_Freshwater:
1903  case tole_River:
1904  case tole_Saltwater:
1905  case tole_LargeRoad:
1906  case tole_Building:
1907  case tole_Coast:
1908  case tole_DeciduousForest:
1909  case tole_ConiferousForest:
1910  return false;
1911  default:
1912  break;
1913  }
1914  }
1915  }
1916  return true; //returns true if both the diagonal and widened part dont hit return false
1917  }
1918  }
1919  }
1920  return true;
1921 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110

References Population_Manager::m_TheLandscape, Landscape::SupplyElementType(), Landscape::SupplyPolyRef(), tole_Building, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_DeciduousForest, tole_Freshwater, tole_HeritageSite, tole_LargeRoad, tole_MetalledPath, tole_Pond, tole_River, tole_Saltmarsh, tole_Saltwater, and tole_Stream.

Referenced by FindClosestMale().

◆ Catastrophe()

void Vole_Population_Manager::Catastrophe ( void  )
protectedvirtual

This version simply alters populations after 1st January - it is very dangerous to add individuals in many of the models so beware!!!!

Reimplemented from Population_Manager.

3630  {
3634  // First do we have the right day?
3635  int today = m_TheLandscape->SupplyDayInYear();
3636  if (today!=1) return;
3637  // First do we have the right year?
3639  if (year%cfg_pm_eventfrequency.value()!=0) return;
3640 
3641  Vole_Male* MV = NULL; // assignment to get rid of warning
3642  Vole_Female* FV = NULL;
3643  Vole_Base* VB = NULL;
3644  // Now if the % decrease is higher or lower than 100 we need to do different things
3645  int esize=cfg_pm_eventsize.value();
3646  if (esize<100) {
3647  unsigned size2 = (unsigned)GetLiveArraySize(vob_Male);
3648  for ( unsigned j = 0; j < size2; j++ ) {
3649  if (random(100) > esize) {
3650  MV = dynamic_cast < Vole_Male * > ( TheArray[ vob_Male ] [ j ] );
3651  MV->CurrentVState=tovs_MDying; // Kill it
3652  }
3653  }
3654  size2 = (unsigned)GetLiveArraySize(vob_Female);
3655  for ( unsigned j = 0; j < size2; j++ ) {
3656  if (random(100) > esize) {
3657  FV = dynamic_cast < Vole_Female * > ( TheArray[ vob_Female ] [ j ] );
3658  FV->CurrentVState=tovs_FDying; // Kill it
3659  }
3660  }
3661  }
3662  else if (esize>100) {
3663  // This is a tricky thing to do because we need to duplicate voles, but dare not mess
3664  // mate pointers etc up.
3665  // This also requires a copy method in the target vole
3666  // esize also needs translating 120 = 20%, 200 = 100%
3667  if (esize<200) {
3668  esize-=100;
3669  for (int i= (int)vob_JuvenileMale; i<= (int)vob_Female; i++) {
3670  unsigned size2;
3671  size2 = (unsigned)GetLiveArraySize(i);
3672  for ( unsigned j = 0; j < size2; j++ ) {
3673  if (random(100) < esize) {
3674  VB = dynamic_cast < Vole_Base * > ( TheArray[ i ] [ j ] );
3675  VB->CopyMyself((VoleObject)i); // Duplicate it
3676  }
3677  }
3678  }
3679  } else {
3680  esize-=100;
3681  esize/=100; // this will throw away fractional parts so will get 1, 2, 3 from 200, 350 400
3682  for (int i= (int)vob_JuvenileMale; i<= (int)vob_Female; i++) {
3683  unsigned size2;
3684  size2 = (unsigned)GetLiveArraySize(i);
3685  for ( unsigned j = 0; j < size2; j++ ) {
3686  for ( int e=0; e<esize; e++) {
3687  VB = dynamic_cast < Vole_Base * > ( TheArray[ i ] [ j ] );
3688  VB->CopyMyself((VoleObject)i); // Duplicate it
3689  }
3690  }
3691  }
3692  }
3693  }
3694  else return; // No change so do nothing
3695 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
CfgInt cfg_pm_eventsize
CfgInt cfg_pm_eventfrequency
int value(void)
Definition: configurator.h:98
int SupplyYearNumber(void)
Definition: landscape.h:1616
int SupplyDayInYear(void)
Definition: landscape.h:1596
int m_catastrophestartyear
Definition: PopulationManager.h:532
unsigned GetLiveArraySize(int a_listindex)
Gets the number of 'live' objects for a list index in the TheArray.
Definition: PopulationManager.h:433
Base class for voles - all vole objects are descended from this class.
Definition: vole_all.h:153
void CopyMyself(VoleObject a_vole)
Duplicates a vole.
Definition: Vole_all.cpp:313
TTypeOfVoleState CurrentVState
Definition: vole_all.h:407
The class for female voles.
Definition: vole_all.h:571
The class for male voles.
Definition: vole_all.h:493
VoleObject
Definition: vole_all.h:99
@ vob_JuvenileMale
Definition: vole_all.h:100
@ vob_Male
Definition: vole_all.h:102
@ vob_Female
Definition: vole_all.h:103
@ tovs_MDying
Definition: vole_all.h:63
@ tovs_FDying
Definition: vole_all.h:73

References cfg_pm_eventfrequency, cfg_pm_eventsize, Vole_Base::CopyMyself(), Vole_Base::CurrentVState, Population_Manager::GetLiveArraySize(), Population_Manager::m_catastrophestartyear, Population_Manager::m_TheLandscape, random(), Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, tovs_FDying, tovs_MDying, CfgInt::value(), vob_Female, vob_JuvenileMale, and vob_Male.

◆ CloseResistanceOutput()

void Vole_Population_Manager::CloseResistanceOutput ( )

Closes the output file ready for resistance results.

4225 {
4226  if (!m_VoleResistanceOutputFile->is_open()) m_VoleResistanceOutputFile->close();
4228 }
ofstream * m_VoleResistanceOutputFile
Definition: VolePopulationManager.h:195

References m_VoleResistanceOutputFile.

Referenced by ~Vole_Population_Manager().

◆ CloseSexRatiosProbe()

void Vole_Population_Manager::CloseSexRatiosProbe ( )
protected

Close the sex ratio probe

3905  {
3906  if ( SexRatiosPrb )
3907  fclose( SexRatiosPrb );
3908  SexRatiosPrb=NULL;
3909 }
FILE * SexRatiosPrb
Definition: VolePopulationManager.h:198

References SexRatiosPrb.

Referenced by ~Vole_Population_Manager().

◆ CreateObjects()

void Vole_Population_Manager::CreateObjects ( VoleObject  ob_type,
TAnimal pvo,
struct_Vole_Adult as,
int  number 
)

Creates 'number' of vole objects of the type ob_type using 'as' for the base data

3456 {
3457  Vole_JuvenileMale* new_JMale;
3458  Vole_JuvenileFemale* new_JFemale;
3459  Vole_Male* new_Male;
3460  Vole_Female* new_Female;
3461 
3462  for (int i = 0; i < number; i++)
3463  {
3464  if (ob_type == vob_JuvenileMale)
3465  {
3466  if (unsigned(TheArray[ob_type].size()) > GetLiveArraySize(ob_type)) {
3467  // We need to reuse an object
3468  dynamic_cast<Vole_JuvenileMale*>(TheArray[ob_type][GetLiveArraySize(ob_type)])->ReInit(as);
3469  IncLiveArraySize(ob_type);
3470  }
3471  else {
3472  new_JMale = new Vole_JuvenileMale(as);
3473  TheArray[ob_type].push_back(new_JMale);
3474  m_VoleMap->SetMapValue(as->x, as->y, (TAnimal*)new_JMale);
3475  IncLiveArraySize(ob_type);
3476  }
3477 
3478 #ifdef __VOLEPESTICIDEON
3479  if (as->m_dflag)
3480  { // Chromo 1. direct effect
3481  new_JMale->SetDirectFlag();
3482  new_JMale->SetGeneticFlag();
3483  if (g_rand_uni() >= m_f1sterilitychance) new_JMale->SetFertile(true);
3484  else new_JMale->SetFertile(false); //
3485  new_JMale->SetPesticideInfluenced2(true);
3486  }
3487  else
3488  {
3489  if (as->m_gflag)
3490  { // Chromo 0, genetic effect
3491  new_JMale->UnsetDirectFlag();
3492  new_JMale->SetGeneticFlag();
3493  if (g_rand_uni() >= m_geneticsterilitychance) new_JMale->SetFertile(true); //100 means all are sterile, 0 means none are
3494  else new_JMale->SetFertile(false);
3495  new_JMale->SetPesticideInfluenced2(true);
3496  }
3497  else
3498  {
3499  new_JMale->UnsetGeneticFlag();
3500  new_JMale->UnsetDirectFlag();
3501  new_JMale->SetFertile(true);
3502  }
3503  }
3504 #endif
3505  }
3506  if (ob_type == vob_JuvenileFemale)
3507  {
3508  if (unsigned(TheArray[ob_type].size()) > GetLiveArraySize(ob_type)) {
3509  // We need to reuse an object
3510  dynamic_cast<Vole_JuvenileFemale*>(TheArray[ob_type][GetLiveArraySize(ob_type)])->ReInit(as);
3511  IncLiveArraySize(ob_type);
3512  }
3513  else {
3514  new_JFemale = new Vole_JuvenileFemale(as);
3515  TheArray[ob_type].push_back(new_JFemale);
3516  m_VoleMap->SetMapValue(as->x, as->y, (TAnimal*)new_JFemale);
3517  IncLiveArraySize(ob_type);
3518  }
3519 
3520 #ifdef __VOLEPESTICIDEON
3521  new_JFemale->SetMaturityDelay(as->misc_use);
3522 #endif
3523  }
3524  if (ob_type == vob_Male)
3525  {
3526  if (unsigned(TheArray[ob_type].size()) > GetLiveArraySize(ob_type)) {
3527  // We need to reuse an object
3528  dynamic_cast<Vole_Male*>(TheArray[ob_type][GetLiveArraySize(ob_type)])->ReInit(as);
3529  IncLiveArraySize(ob_type);
3530  }
3531  else {
3532  new_Male = new Vole_Male(as);
3533  TheArray[ob_type].push_back(new_Male);
3534  m_VoleMap->SetMapValue(as->x, as->y, (TAnimal*)new_Male);
3535  IncLiveArraySize(ob_type);
3536  }
3537 
3538 #ifdef __VOLEPESTICIDEON
3539  if (as->m_dflag)
3540  { // Chromo 1. direct effect
3541  new_Male->SetDirectFlag();
3542  new_Male->SetGeneticFlag();
3543  if (g_rand_uni() >= m_f1sterilitychance) new_Male->SetFertile(true);
3544  else new_Male->SetFertile(false); //
3545  new_Male->SetPesticideInfluenced2(true);
3546  }
3547  else
3548  {
3549  if (as->m_gflag)
3550  { // Chromo 0, genetic effect
3551  new_Male->UnsetDirectFlag();
3552  new_Male->SetGeneticFlag();
3553  if (g_rand_uni() >= m_geneticsterilitychance) new_Male->SetFertile(true); //100 means all are sterile, 0 means none are
3554  else new_Male->SetFertile(false);
3555  new_Male->SetPesticideInfluenced2(true);
3556  }
3557  else
3558  {
3559  new_Male->UnsetGeneticFlag();
3560  new_Male->UnsetDirectFlag();
3561  new_Male->SetFertile(true);
3562  }
3563  }
3564 #endif
3565  }
3566  if (ob_type == vob_Female)
3567  {
3568  if (unsigned(TheArray[ob_type].size()) > GetLiveArraySize(ob_type)) {
3569  // We need to reuse an object
3570  dynamic_cast<Vole_Female*>(TheArray[ob_type][GetLiveArraySize(ob_type)])->ReInit(as);
3571  IncLiveArraySize(ob_type);
3572  }
3573  else {
3574  new_Female = new Vole_Female(as);
3575  TheArray[ob_type].push_back(new_Female);
3576  m_VoleMap->SetMapValue(as->x, as->y, (TAnimal*)new_Female);
3577  IncLiveArraySize(ob_type);
3578  }
3579  }
3580  }
3581 }
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
void SetMapValue(unsigned x, unsigned y, a_type p)
Definition: MovementMap.h:105
void IncLiveArraySize(int a_listindex)
Increments the number of 'live' objects for a list index in the TheArray.
Definition: PopulationManager.h:437
The base class for all ALMaSS animal classes.
Definition: PopulationManager.h:205
void SetGeneticFlag()
Definition: vole_all.h:394
void UnsetGeneticFlag()
Definition: vole_all.h:398
void UnsetDirectFlag()
Definition: vole_all.h:400
void SetFertile(bool f)
Set the male vole fertility.
Definition: vole_all.h:414
void SetDirectFlag()
Definition: vole_all.h:396
The class for female voles.
Definition: vole_all.h:529
The class for juvenile male voles.
Definition: vole_all.h:453
int y
Definition: vole_all.h:126
bool m_gflag
Definition: vole_all.h:143
int x
Definition: vole_all.h:125
bool m_dflag
Definition: vole_all.h:144
double misc_use
Definition: vole_all.h:145
@ vob_JuvenileFemale
Definition: vole_all.h:101

References g_rand_uni, Population_Manager::GetLiveArraySize(), Population_Manager::IncLiveArraySize(), struct_Vole_Adult::m_dflag, struct_Vole_Adult::m_gflag, m_VoleMap, struct_Vole_Adult::misc_use, Vole_Base::SetDirectFlag(), Vole_Base::SetFertile(), Vole_Base::SetGeneticFlag(), IDMap< a_type >::SetMapValue(), Population_Manager::TheArray, Vole_Base::UnsetDirectFlag(), Vole_Base::UnsetGeneticFlag(), vob_Female, vob_JuvenileFemale, vob_JuvenileMale, vob_Male, struct_Vole_Adult::x, and struct_Vole_Adult::y.

Referenced by Vole_Base::CopyMyself(), Vole_JuvenileMale::st_BecomeSubAdult(), Vole_JuvenileFemale::st_BecomeSubAdult(), and Vole_Female::st_Lactating().

◆ CreateObjects_Init()

void Vole_Population_Manager::CreateObjects_Init ( VoleObject  ob_type,
TAnimal pvo,
struct_Vole_Adult data,
int  number 
)

Creates 'number' of vole objects of the type ob_type using 'as' for the base data for use at the beginning of a simulation.
A number of the attributes are set at defaults or randomised

3590 {
3591  struct_Vole_Adult *as=NULL;
3592  int Year = m_TheLandscape->SupplyYearNumber();
3593 
3594  for (int i=0; i<number; i++)
3595  {
3596  if (ob_type == vob_Male)
3597  {
3598  Vole_Male* new_Male;
3599  as=dynamic_cast<struct_Vole_Adult *>(data);
3600  as->FatherId = 10000000;
3601  as->MotherId = 10000000;
3602  as->FatherStateAtBirth = 2;
3603  new_Male = new Vole_Male(as);
3604  TheArray[ob_type].push_back(new_Male);
3605  new_Male->SetWeight(40.0);
3606  new_Male->Setm_Mature();
3607  new_Male->Set_Age(random(500));
3608  new_Male->Set_BirthYear(Year);
3609  new_Male->SetFertile(true);
3610  }
3611  if (ob_type == vob_Female)
3612  {
3613  Vole_Female* new_Female;
3614  as=dynamic_cast<struct_Vole_Adult *>(data);
3615  as->FatherId = 10000000;
3616  as->MotherId = 10000000;
3617  as->FatherStateAtBirth = 2;
3618  new_Female = new Vole_Female(as);
3619  TheArray[ob_type].push_back(new_Female);
3620  new_Female->SetWeight(40.0);
3621  new_Female->Setm_Mature();
3622  new_Female->Set_Age(1); // (random(500))
3623  new_Female->Set_BirthYear(Year);
3624  }
3625  IncLiveArraySize(ob_type);
3626  }
3627 }
void Set_BirthYear(int BirthYear)
Definition: vole_all.h:302
void Setm_Mature()
Definition: vole_all.h:300
void SetWeight(double W)
Definition: vole_all.h:298
void Set_Age(int Age)
Definition: vole_all.h:329
A struct for passing data to create a new vole.
Definition: vole_all.h:123
int FatherStateAtBirth
Definition: vole_all.h:137
int FatherId
Definition: vole_all.h:135
int MotherId
Definition: vole_all.h:136

References struct_Vole_Adult::FatherId, struct_Vole_Adult::FatherStateAtBirth, Population_Manager::IncLiveArraySize(), Population_Manager::m_TheLandscape, struct_Vole_Adult::MotherId, random(), Vole_Base::Set_Age(), Vole_Base::Set_BirthYear(), Vole_Base::SetFertile(), Vole_Base::Setm_Mature(), Vole_Base::SetWeight(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, vob_Female, and vob_Male.

Referenced by Init().

◆ DoFirst()

void Vole_Population_Manager::DoFirst ( void  )
protectedvirtual

Can be used in descendent classes

This method is called before the BeginStep of the main program loop by the base class.
It controls when the grass starts to grow and therefore triggers start of reproduction but the primary role is as a safe location where outputs can be generated. At the time this is called there no chance that the voles are engaged in any kind of activity.

First job is to calculate a basic quality for each polygon. This is more efficient than getting the voles to do the calculation each time they need to know.

Reimplemented from Population_Manager.

550 {
563  //for (int type = 0; type<vob_foobar; type++)
564  //{
565  // int s = (int) TheArray[type].size();
566  // for (int i = 0; i<s; i++) m_TheLandscape->IncVoleGrazing(TheArray[type][i]->Supply_m_Location_x(), TheArray[type][i]->Supply_m_Location_y());
567  //}
568  //m_TheLandscape->CalcAllVoleGrazingDensity();
569  unsigned sz = m_TheLandscape->SupplyNumberOfPolygons();
570  for (unsigned p = 0; p<sz; p++)
571  {
572  double qual = AssessHabitat(p);
573  //double volegrazing = m_TheLandscape->SupplyVoleGrazingDensityVector(p);
574  //if (volegrazing<m_BaseVoleDensity) volegrazing = m_BaseVoleDensity;
575  //VoleHabitatBaseQualities[p] = qual / (volegrazing/m_BaseVoleDensity);
576  VoleHabitatBaseQualities[p] = qual;
577  }
578 
579 
580  int year = m_TheLandscape->SupplyYearNumber();
581  if (year > -1)
582  {
585  }
586  else
587  {
588  g_DailyMortChance = 0;
589  g_extradispmort = 0;
590  }
591 
592  int today=m_TheLandscape->SupplyDayInYear();
593  if (today==0) {
594  m_GrowthStartDate=9000;
595  }
596  if ((today>cfg_GrassStartGrowthDay.value())&& (m_GrowthStartDate==9000))
597  {
600  {
601  m_GrowthStartDate = today;
602  printf("The start day is: %d\n",today);
603  }
604  }
605  if (GetLiveArraySize(vob_Female) > 0)
606  {
607  if ((today>SupplyGrowthStartDate())&&(today<=g_MaleReproductFinish))
608  {
609  dynamic_cast<Vole_Female*>(TheArray[vob_Female][0])->SetBreedingSeason( true );
611  }
612  else
613  {
614  dynamic_cast<Vole_Female*>(TheArray[vob_Female][0])->SetBreedingSeason( false );
615  // Below could be used to alter mortality outside breeding season - currently unused (did not help POM fit)
617  }
618  };
619 
620 
621  //** OUTPUT BELOW HERE **
623  if (year>=cfg_SexRatiosOutputFirstYear.value()) {
624  if ( year % cfg_SexRatiosOutput_interval.value() == 0 ) {
625  if (( cfg_SexRatiosOutput_day.value() == today )||( cfg_SexRatiosOutput_day.value() == -1 )) {
627  }
628  }
629  }
630  }
637  //AgeYoungKilledToday=0;
638  YoungProducedToday=0; // Zero the number of young
639  JuvsProducedToday=0; // Zero the number of juveniles
640  if (today==0)
641  {
642  // Annual Vole Mortality Record Operations
645 #ifdef __VOLEPESTICIDEON
646  // Save the impacted file
647  FILE* impf = fopen("Impacted.res","a");
648  if (!impf) {
649  m_TheLandscape->Warn("Vole_Population_Manager Destructor","Could Not Open Impacted.Res File");
650  exit(0);
651  }
652  fprintf(impf,"%d\t%d\t%d\t%d\t%d\n",m_notimpacted, m_impacted, m_geneticimpacted, m_LittersProduced, m_LittersLost);
653  fclose(impf);
654  m_impacted=0;
655  m_notimpacted=0;
656  m_geneticimpacted=0;
657  m_LittersLost=0;
658  m_LittersProduced = 0;
659 #endif
660  }
662  // Open genetic output file for append
663  int no_samples = cfg_genetetic_output_sample_size.value();
664  fstream gfout;
665  gfout.open("VoleGeneticsOutput.txt",ios::app);
666  if (!gfout) {
667  g_msg->Warn( "Population_Manager::SpeciesSpecificReporting(int a_species, int a_time) ","Cannot open file VoleGeneticsOutput.txt for append" );
668  exit( 0 );
669  }
670  // Select voles and print their genetics and location to the file
671  // Simplest is to randomise the list of males and females, then take the first 500 of each
673  Shuffle(vob_Male);
674  //
675  int x = 0; int y = 0;
676  int s = (int)GetLiveArraySize(vob_Female);
677  if ( s > no_samples ) s = no_samples;
678  for (int i = 0; i<s; i++) {
679  Vole_Female* VF = dynamic_cast<Vole_Female*>(TheArray[vob_Female][i]);
680  gfout << year << '\t';
681  x = VF->Supply_m_Location_x();
682  y = VF->Supply_m_Location_y();
683  gfout << x << '\t' << y << '\t' << "F";
684  for (int a=0; a<16; a++) {
685  int allele1 = 1 + VF->SupplyAllele(a,0);
686  int allele2 = 1 + VF->SupplyAllele(a,1);
687  gfout << '\t' << allele1 << '\t' << allele2;
688  }
689  gfout << endl;
690  }
691  s = (int)GetLiveArraySize(vob_Male);
692  if ( s > no_samples ) s = no_samples;
693  for (int i = 0; i<s; i++) {
694  Vole_Male* VM = dynamic_cast<Vole_Male*>(TheArray[vob_Male][i]);
695  gfout << year << '\t';
696  x = VM->Supply_m_Location_x();
697  y = VM->Supply_m_Location_y();
698  gfout << x << '\t' << y << '\t' << "M";
699  for (int a=0; a<16; a++) {
700  int allele1 = 1 + VM->SupplyAllele(a,0);
701  int allele2 = 1 + VM->SupplyAllele(a,1);
702  gfout << '\t' << allele1 << '\t' << allele2;
703  }
704  gfout << endl;
705  }
706  gfout.close();
707  }
708 
710  {
712  }
713 
714 
715  bool terr = false;
716  if ( cfg_UseVoleTraplines.value() ) {
717  int day = m_TheLandscape->SupplyGlobalDate();
718  // Loop through all voles and see if any of them are in trap locations
719  int s = (int)GetLiveArraySize(vob_JuvenileMale);
720  for (int i = 0; i<s; i++) {
722  if ( VJM->SupplyInTrap()) {
724  m_Traplines->Output(tp, day, vob_JuvenileMale, false , VJM->SupplyAge(),VJM->SupplyXBorn(),VJM->SupplyYBorn(), VJM->SupplyIDNo() );
725  VJM->SetFree();
726  }
727  }
728 
730  for (int i = 0; i<s; i++) {
732  if ( VJF->SupplyInTrap()) {
734  m_Traplines->Output(tp, day, vob_JuvenileFemale, false , VJF->SupplyAge(),VJF->SupplyXBorn(),VJF->SupplyYBorn(), VJF->SupplyIDNo() );
735  VJF->SetFree();
736  }
737  }
738 
739  s = (int)GetLiveArraySize(vob_Female);
740  for (int i = 0; i<s; i++) {
741  Vole_Female* VF = dynamic_cast<Vole_Female*>(TheArray[vob_Female][i]);
742  if ( VF->SupplyInTrap()) {
744  terr = VF->SupplyTerritorial();
745  m_Traplines->Output(tp, day, vob_Female, terr, VF->SupplyAge(),VF->SupplyXBorn(),VF->SupplyYBorn(), VF->SupplyIDNo() );
746  VF->SetFree();
747  }
748  }
749 
750  s = (int)GetLiveArraySize(vob_Male);
751  for (int i = 0; i<s; i++) {
752  Vole_Male* VM = dynamic_cast<Vole_Male*>(TheArray[vob_Male][i]);
753  if ( VM->SupplyInTrap()) {
755  terr = VM->SupplyTerritorial();
756  m_Traplines->Output(tp, day, vob_Male, terr, VM->SupplyAge(),VM->SupplyXBorn(),VM->SupplyYBorn(), VM->SupplyIDNo() );
757  VM->SetFree();
758  }
759  }
760  }
762  {
764  }
765 }
static CfgFloat cfg_GrassStartGrowthDay("VOLE_GRASSSTARTGROWTHDAY", CFG_CUSTOM, 80)
double g_DailyMortChanceMaleTerr
Definition: Vole_all.cpp:190
static CfgInt cfg_genetetic_output_sample_size("VOLE_GENETIC_SAMPLE_SIZE", CFG_CUSTOM, 500)
static CfgInt cfg_GeneticsResultOutputFirstYear("GENETICS_RESULT_OUTPUT_FIRST_YEAR", CFG_CUSTOM, 100000)
static CfgInt cfg_GeneticsResultOutputInterval_1("GENETICS_RESULT_OUTPUT_INTERVAL_ONE", CFG_CUSTOM, 100000)
double g_extradispmort
Definition: Vole_all.cpp:204
static CfgFloat cfg_VoleBackgroundMort("VOLE_BCKMORT", CFG_CUSTOM, 0.0025)
int g_MaleReproductFinish
Definition: Vole_all.cpp:183
CfgFloat cfg_extradispmort
static CfgFloat cfg_GrassStartGrowth("VOLE_GRASSSTARTGROWTH", CFG_CUSTOM, 3.552)
static CfgInt cfg_SexRatiosOutputFirstYear("VOLE_SEXRATIOSOUTPUT_FIRSTYEAR", CFG_CUSTOM, 1)
static CfgInt cfg_voleLandscapeGridOutputDay("VOLE_LANDSCAPEGRIDOUTPUTDAY", CFG_CUSTOM, 10000)
static CfgInt cfg_SexRatiosOutput_day("VOLE_SEXRATIOSOUTPUT_DAY", CFG_CUSTOM, -1)
static CfgInt cfg_SexRatiosOutput_interval("VOLE_SEXRATIOSOUTPUT_INTERVAL", CFG_CUSTOM, 1)
static CfgInt cfg_VoleResistanceDay("VOLE_RESISTANCEOUTPUT_DAY", CFG_CUSTOM, 365)
double g_DailyMortChance
Definition: Vole_all.cpp:189
class Calendar * g_date
Definition: calendar.cpp:38
int GetDayInMonth(void)
Definition: calendar.h:72
double value(void)
Definition: configurator.h:118
A class for storing the position of the trap the vole is in.
Definition: vole_all.h:113
long SupplyGlobalDate(void)
Definition: landscape.h:1621
double SupplyMeanTemp(long a_date, unsigned int a_period)
Definition: landscape.h:1372
unsigned int SupplyNumberOfPolygons(void)
Definition: landscape.h:1461
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
void Shuffle(unsigned Type)
Definition: PopulationManager.cpp:1055
int Supply_m_Location_x()
Definition: PopulationManager.h:213
int Supply_m_Location_y()
Definition: PopulationManager.h:216
void Output(InTrapPosition a_tp, int a_day, int a_sex, bool a_terr, int a_age, int a_bx, int a_by, int a_ID)
Definition: VolePopulationManager.cpp:3989
int SupplyIDNo()
Definition: vole_all.h:364
int SupplyAllele(int locus, int allele)
Definition: vole_all.h:386
int SupplyXBorn()
Definition: vole_all.h:348
InTrapPosition SupplyTrapPosition()
Definition: vole_all.h:378
unsigned SupplyAge()
Definition: vole_all.h:370
bool SupplyInTrap()
Definition: vole_all.h:376
int SupplyYBorn()
Definition: vole_all.h:350
bool SupplyTerritorial()
Definition: vole_all.h:336
void SetFree()
Definition: vole_all.h:380
double AssessHabitat(int p_Polyref)
Assess the quality of habitat at p_Polyref.
Definition: VolePopulationManager.cpp:771
virtual void LandscapeQuadrantOutputProbe(int a_day)
Definition: VolePopulationManager.cpp:3698
void ResistanceOutput()
Resistance results file output
Definition: VolePopulationManager.cpp:4231
int SupplyGrowthStartDate()
Definition: VolePopulationManager.h:237
vector< double > VoleHabitatBaseQualities
Definition: VolePopulationManager.h:172
bool RecordGeneticsToday(int p_today, int p_year, int p_start_year, int p_interval)
Definition: VolePopulationManager.cpp:1007
virtual void TheSexRatiosProbe()
Definition: VolePopulationManager.cpp:3916
void TheAgeSexLocationProbe()
Definition: VolePopulationManager.cpp:3780
void ResetData()
Definition: VolePopulationManager.cpp:4043
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41

References AssessHabitat(), cfg_extradispmort, cfg_genetetic_output_sample_size, cfg_GeneticsResultOutputFirstYear, cfg_GeneticsResultOutputInterval_1, cfg_GrassStartGrowth, cfg_GrassStartGrowthDay, cfg_RecordVoleMort, cfg_SexRatiosOutput_day, cfg_SexRatiosOutput_interval, cfg_SexRatiosOutput_used, cfg_SexRatiosOutputFirstYear, cfg_useagesexlocation, cfg_UseVoleTraplines, cfg_VoleBackgroundMort, cfg_voleLandscapeGridOutputDay, cfg_VoleResistanceDay, cfg_VoleUseResistanceOuput, g_DailyMortChance, g_DailyMortChanceMaleTerr, g_date, g_extradispmort, g_MaleReproductFinish, g_msg, Calendar::GetDayInMonth(), Population_Manager::GetLiveArraySize(), JuvsProducedToday, LandscapeQuadrantOutputProbe(), m_GrowthStartDate, Population_Manager::m_TheLandscape, m_Traplines, m_VoleRecordMort, NoYoungKilledToday, NoYoungKilledToday4, NoYoungKilledToday8, NoYoungKilledToday9, VoleSummaryOutput::OPrint(), TrapLineMap::Output(), RecordGeneticsToday(), VoleSummaryOutput::ResetData(), ResistanceOutput(), Vole_Base::SetFree(), Population_Manager::Shuffle(), TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Vole_Base::SupplyAge(), Vole_Base::SupplyAllele(), Landscape::SupplyDayInYear(), Landscape::SupplyGlobalDate(), SupplyGrowthStartDate(), Vole_Base::SupplyIDNo(), Vole_Base::SupplyInTrap(), Landscape::SupplyMeanTemp(), Landscape::SupplyNumberOfPolygons(), Vole_Base::SupplyTerritorial(), Vole_Base::SupplyTrapPosition(), Vole_Base::SupplyXBorn(), Vole_Base::SupplyYBorn(), Landscape::SupplyYearNumber(), TheAgeSexLocationProbe(), Population_Manager::TheArray, TheSexRatiosProbe(), CfgInt::value(), CfgFloat::value(), CfgBool::value(), vob_Female, vob_JuvenileFemale, vob_JuvenileMale, vob_Male, VoleHabitatBaseQualities, MapErrorMsg::Warn(), Landscape::Warn(), and YoungProducedToday.

◆ FindClosestFemale()

Vole_Female * Vole_Population_Manager::FindClosestFemale ( int  p_x,
int  p_y,
int  p_steps 
)

looks for the closest female within p_Steps of p_x,p_y

2228 {
2230  // as usual there are 4 possibilities of overlap
2231  // First convert centre co-rdinates to square co-ordinates
2232 
2233  int x=p_x - p_steps;
2234  if (x<0) x+=SimW; // ensure we start in the simulation area!
2235  int y=p_y - p_steps;
2236  if (y<0) y+=SimH;
2237  int range_x=p_steps*2;
2238  int range_y=p_steps*2;
2239 
2240  // create the extent variables
2241  int xextent0 = x+range_x;
2242  int yextent0 = y+range_y;
2243  int xextent1 = (x+range_x)-SimW;
2244  int yextent1 = (y+range_y)-SimH;
2245  // Create the looping variables needed
2246  // Create the looping variables needed
2247  int Dfinx;
2248  int Dfiny;
2249  int Afinx=0; //unless the finx values for A are changed this stop
2250  int Afiny=0; //the loop from executing
2251  int Asty=0;
2252  // int Astx,Dstx,Dtsy are always default so variables not used from them
2253  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
2254  // Dsty is always y, Afiny is always yextent1 if it is used
2255  // Now create the loop values;
2256  if (xextent0<=SimW) // No overlap with the eastern side
2257  {
2258  // Dstx, Dsty, Asty set by defaults
2259  //Astx & Afinx are not needed
2260  Dfinx=xextent0;
2261  // do we overlap the bottom?
2262  // Type B & D (overlap bottom, no overlap)
2263  if (yextent0>SimH)
2264  {
2265  // Type B (overlap bottom only)
2266  Dfiny=SimH; // stop at the end
2267  Afiny=yextent1; // the overlap with the top
2268  }
2269  else Dfiny=yextent0;
2270  }
2271  else
2272  {
2273  // Type A & C overlap bottom & eastern edgdes
2274  if (yextent0>SimH)
2275  {
2276  // relies on the default start for Asty, Astx, Dstx, Dsty
2277  Afinx=xextent1;
2278  Afiny=yextent1;
2279  Dfinx=SimW; // Stop at the end
2280  Dfiny=SimH;
2281  }
2282  else
2283  {
2284  // Type C overlap left edge only
2285  // Astx & Afiny are not needed here
2286  //Astx, Dstx, Dsty set by default
2287  Afinx=xextent1;
2288  Dfinx=SimW; // Stop at the end
2289  Dfiny=yextent0;
2290  }
2291  }
2292  Vole_Female* AFemale;
2293  Vole_Female* Found=NULL;
2294  int dist, disty;
2295  int FoundDist=SimW; // too big
2296  Vole_Base* Ap;
2297 
2298  // A Loop
2299  for (int i=0; i<Afinx; i++)
2300  {
2301  for (int j=Asty; j<Afiny; j++)
2302  {
2303  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2304  if (Ap)
2305  {
2306  if (!Ap->SupplySex()) // female
2307  {
2308  AFemale=(Vole_Female*) (Ap) ;
2309  if (AFemale->SupplyTerritorial())
2310  {
2311  dist=abs(p_x-i); // remove the signed bit
2312  disty=abs(p_y-j);
2313  dist+=disty;
2314  if (dist<FoundDist)
2315  {
2316  Found=AFemale;
2317  FoundDist=dist;
2318  }
2319  }
2320  }
2321  }
2322  }
2323  // C Loop
2324  for (int j=y; j<Dfiny; j++)
2325  {
2326  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2327  if (Ap)
2328  {
2329  if (!Ap->SupplySex()) // female
2330  {
2331  AFemale=(Vole_Female*) (Ap) ;
2332  if (AFemale->SupplyTerritorial())
2333  {
2334  dist=abs(p_x-i); // remove the signed bit
2335  disty=abs(p_y-j);
2336  dist+=disty;
2337  if (dist<FoundDist)
2338  {
2339  Found=AFemale;
2340  FoundDist=dist;
2341  }
2342  }
2343  }
2344  }
2345  }
2346  }
2347  // D Loop
2348  for (int i=x; i<Dfinx; i++)
2349  {
2350  for (int j=y; j<Dfiny; j++)
2351  {
2352  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2353  if (Ap)
2354  {
2355  if (!Ap->SupplySex()) // female
2356  {
2357  AFemale=(Vole_Female*) (Ap) ;
2358  if (AFemale->SupplyTerritorial())
2359  {
2360  dist=abs(p_x-i); // remove the signed bit
2361  disty=abs(p_y-j);
2362  dist+=disty;
2363  if (dist<FoundDist)
2364  {
2365  Found=AFemale;
2366  FoundDist=dist;
2367  }
2368  }
2369  }
2370  }
2371  }
2372  // B Loop
2373  for (int j=0; j<Afiny; j++)
2374  {
2375  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2376  if (Ap)
2377  {
2378  if (!Ap->SupplySex()) // female
2379  {
2380  AFemale=(Vole_Female*) (Ap) ;
2381  if (AFemale->SupplyTerritorial())
2382  {
2383  dist=abs(p_x-i); // remove the signed bit
2384  disty=abs(p_y-j);
2385  dist+=disty;
2386  if (dist<FoundDist)
2387  {
2388  Found=AFemale;
2389  FoundDist=dist;
2390  }
2391  }
2392  }
2393  }
2394  }
2395  }
2396  return Found;
2397 }
a_type GetMapValue(unsigned x, unsigned y)
Definition: MovementMap.h:102
int SimH
Definition: PopulationManager.h:511
int SimW
Definition: PopulationManager.h:511
bool SupplySex()
Definition: vole_all.h:342

References IDMap< a_type >::GetMapValue(), m_VoleMap, Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplySex(), and Vole_Base::SupplyTerritorial().

Referenced by Vole_Male::st_Eval_n_Explore().

◆ FindClosestMale()

Vole_Male * Vole_Population_Manager::FindClosestMale ( int  p_x,
int  p_y,
int  p_steps 
)

looks for the closest male within p_Steps of p_x,p_y

2687 {
2689  // as usual there are 4 possibilities of overlap
2690  // First convert centre co-rdinates to square co-ordinates
2691  int x=p_x - p_steps;
2692  if (x<0) x+=SimW; // ensure we start in the simulation area!
2693  int y=p_y - p_steps;
2694  if (y<0) y+=SimH;
2695  int range_x=p_steps*2;
2696  int range_y=p_steps*2;
2697 
2698  // create the extent variables
2699  int xextent0 = x+range_x;
2700  int yextent0 = y+range_y;
2701  int xextent1 = (x+range_x)-SimW;
2702  int yextent1 = (y+range_y)-SimH;
2703  // Create the looping variables needed
2704  // Create the looping variables needed
2705  int Dfinx;
2706  int Dfiny;
2707  int Afinx=0; //unless the finx values for A are changed this stop
2708  int Afiny=0; //the loop from executing
2709  int Asty=0;
2710  // int Astx,Dstx,Dtsy are always default so variables not used from them
2711  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
2712  // Dsty is always y, Afiny is always yextent1 if it is used
2713  // Now create the loop values;
2714  if (xextent0<=SimW) // No overlap with the eastern side
2715  {
2716  // Dstx, Dsty, Asty set by defaults
2717  //Astx & Afinx are not needed
2718  Dfinx=xextent0;
2719  // do we overlap the bottom?
2720  // Type B & D (overlap bottom, no overlap)
2721  if (yextent0>SimH)
2722  {
2723  // Type B (overlap bottom only)
2724  Dfiny=SimH; // stop at the end
2725  Afiny=yextent1; // the overlap with the top
2726  }
2727  else Dfiny=yextent0;
2728  }
2729  else
2730  {
2731  // Type A & C overlap bottom & eastern edgdes
2732  if (yextent0>SimH)
2733  {
2734  // relies on the default start for Asty, Astx, Dstx, Dsty
2735  Afinx=xextent1;
2736  Afiny=yextent1;
2737  Dfinx=SimW; // Stop at the end
2738  Dfiny=SimH;
2739  }
2740  else
2741  {
2742  // Type C overlap left edge only
2743  // Astx & Afiny are not needed here
2744  //Astx, Dstx, Dsty set by default
2745  Afinx=xextent1;
2746  Dfinx=SimW; // Stop at the end
2747  Dfiny=yextent0;
2748  }
2749  }
2750  Vole_Male* AMale;
2751  Vole_Male* Found=NULL;
2752  int dist, disty;
2753  int FoundDist=SimW; // too big
2754  Vole_Base* Ap;
2755  // A Loop
2756  for (int i=0; i<Afinx; i++)
2757  {
2758  for (int j=Asty; j<Afiny; j++)
2759  {
2760  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2761  if (Ap)
2762  {
2763  if (Ap->SupplySex()) // male
2764  {
2765  {
2766  AMale=(Vole_Male*) (Ap) ;
2767  if (AMale->SupplyTerritorial())
2768  {
2769  dist=abs(p_x-i); // remove the signed bit
2770  disty=abs(p_y-j);
2771  dist+=disty;
2772 
2773  if (dist<FoundDist)
2774  {
2775  bool Barrier = BarrierSearch(p_x, p_y, i, j);
2776  if (Barrier == true){
2777  Found=AMale;
2778  FoundDist=dist;
2779  }
2780  }
2781  }
2782  }
2783  }
2784  }
2785  }
2786  // C Loop
2787  for (int j=y; j<Dfiny; j++)
2788  {
2789  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2790  if (Ap)
2791  {
2792  if (Ap->SupplySex()) // male
2793  {
2794  {
2795  AMale=(Vole_Male*) (Ap) ;
2796  if (AMale->SupplyTerritorial())
2797  {
2798  dist=abs(p_x-i); // remove the signed bit
2799  disty=abs(p_y-j);
2800  dist+=disty;
2801 
2802  if (dist<FoundDist)
2803  {
2804  bool Barrier = BarrierSearch(p_x, p_y, i, j);
2805  if (Barrier == true){
2806  Found=AMale;
2807  FoundDist=dist;
2808  }
2809  }
2810  }
2811  }
2812  }
2813  }
2814  }
2815  }
2816  // D Loop
2817  for (int i=x; i<Dfinx; i++)
2818  {
2819  for (int j=y; j<Dfiny; j++)
2820  {
2821  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2822  if (Ap)
2823  {
2824  if (Ap->SupplySex()) // male
2825  {
2826  {
2827  AMale=(Vole_Male*) (Ap) ;
2828  if (AMale->SupplyTerritorial())
2829  {
2830  dist=abs(p_x-i); // remove the signed bit
2831  disty=abs(p_y-j);
2832  dist+=disty;
2833  if (dist<FoundDist)
2834  {
2835  bool Barrier = BarrierSearch(p_x, p_y, i, j);
2836  if (Barrier == true){
2837  Found=AMale;
2838  FoundDist=dist;
2839  }
2840  }
2841  }
2842  }
2843  }
2844  }
2845  }
2846  // B Loop
2847  for (int j=0; j<Afiny; j++)
2848  {
2849  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2850  if (Ap)
2851  {
2852  if (Ap->SupplySex()) // male
2853  {
2854  AMale=(Vole_Male*) (Ap) ;
2855  {
2856 
2857  if (AMale->SupplyTerritorial())
2858  {
2859  dist=abs(p_x-i); // remove the signed bit
2860  disty=abs(p_y-j);
2861  dist+=disty;
2862  if (dist<FoundDist)
2863  {
2864  bool Barrier = BarrierSearch(p_x, p_y, i, j);
2865  if (Barrier == true){
2866  Found=AMale;
2867  FoundDist=dist;
2868  }
2869  }
2870  }
2871  }
2872  }
2873  }
2874  }
2875  }
2876  return Found;
2877 }
bool BarrierSearch(int F_x, int F_y, int M_x, int M_y)
Definition: VolePopulationManager.cpp:1261

References BarrierSearch(), IDMap< a_type >::GetMapValue(), m_VoleMap, Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplySex(), and Vole_Base::SupplyTerritorial().

Referenced by Vole_Female::st_Mating().

◆ FindOutsideRadiusMale()

Vole_Male * Vole_Population_Manager::FindOutsideRadiusMale ( int  p_x,
int  p_y 
)

Returns a pointer to a random male - he does not even have to have a territory

2400 {
2402  int x= (p_x - cfg_MateRadius.value()); // 'left most' x
2403  if (x<0) x+=SimW; // ensure we start within the landscape!
2404  int y= (p_y - cfg_MateRadius.value()); // 'top' y
2405  if (y<0) y+=SimH;
2406  int range_x= (cfg_MateRadius.value()*2); // width of the search area
2407  int range_y= (cfg_MateRadius.value()*2); // hight of the search area
2408 
2409  // create the extent variables - if out of bounds
2410  int xextent0 = x+range_x; // 'right most' x
2411  int yextent0 = y+range_y; // 'lowest'(bottom) y
2412  int xextent1 = (x+range_x)-SimW; // incase we are out of bounds
2413  int yextent1 = (y+range_y)-SimH;
2414 
2415  // Create the looping variables needed
2416  int Dfinx;
2417  int Dfiny;
2418  int Afinx=0; //unless the finx values for A are changed this stop
2419  int Afiny=0; //the loop from executing
2420  //int Asty=0;
2421 
2422  // Dfinx, Dfiny are the stop x and y values for 'the mate picking area'
2423  // Afinx, Afiny are the 'overlapping area' if 'the mate picking area' goes out off bounds
2424  // Set default at 0 and only changes value if out off bounds
2425 
2426  // Now create the loop values;
2427  // Type A (no overlap with the eastern bound)
2428  if (xextent0<=SimW)
2429  {
2430  //Afinx are not needed
2431  Dfinx=xextent0; // because no overlap with the right most bound
2432  // do we overlap the bottom (lowest y)?
2433  // Type B & D (overlap bottom, no overlap)
2434  if (yextent0>SimH)
2435  {
2436  // Type B (overlap bottom only)
2437  Dfiny=SimH; // stop at the end
2438  Afiny=yextent1; // the overlap with the top because off bounds
2439  }
2440  else Dfiny=yextent0; // if no overlap
2441  }
2442  else
2443  {
2444  // Type A & C eastern bound & overlap bottom
2445  if (yextent0>SimH)
2446  {
2447  // relies on the default start for Afiny, Afinx, Dfinx, Dfiny
2448  Afinx=xextent1; // Afinx gets a value other than 0 = overlapping value
2449  Afiny=yextent1; //
2450  Dfinx=SimW; // Stop at the end
2451  Dfiny=SimH;
2452  }
2453  else
2454  {
2455  // Type C overlap west bound only
2456  //Afiny, Dfinx, Dfiny set by default
2457  Afinx=xextent1;
2458  Dfinx=SimW; // Stop at the end
2459  Dfiny=yextent0;
2460  }
2461  }
2462 
2463  Vole_Male* Found=NULL;
2464  TAnimal* Ap;
2465  int size=(int)GetLiveArraySize(vob_Male);
2466 
2467  do
2468  {
2469  int test =random(size);
2470  Ap=TheArray[vob_Male][test]; // Males only
2471  Found=(Vole_Male*)(Ap); // Male pointer to TAnimal[0][test]
2472  int territory = Found->SupplyTerritorial();
2473  if (Found->GetCurrentStateNo() == -1) Found=NULL; // If end of timestep reached skip check
2474  {
2475  int i = Found->Supply_m_Location_x();
2476  int j = Found->Supply_m_Location_y();
2477 
2478  if (Afinx == 0) // no right overlap
2479  {
2480  if (Afiny == 0) // no bottom overlap
2481  {
2482  if (((x <= i) && (i <= Dfinx)) && ((y <= j) && (j <= Dfiny)))
2483  {
2484  Found=NULL;
2485  }
2486  }
2487 
2488  if (Afiny != 0)// overlap bottom
2489  {
2490  if (((x <= i) && (i <= Dfinx)) && ((( 0<= j) && (j <=Afiny)) || ((y <= j) && (j <= Dfiny))))
2491  {
2492  Found=NULL;
2493  }
2494  }
2495  }
2496  if (Afinx !=0) // overlap right
2497  {
2498  if (Afiny == 0)
2499  {
2500  if (((y <= j) && (j <= Dfiny)) && (((0 <= i) && (i <= Afinx)) || ((x <= i) && (i <= Dfinx))))
2501  {
2502  Found=NULL;
2503  }
2504  }
2505 
2506  if (Afiny != 0) //overlap bottom
2507  {
2508  if ((( 0 <= i) && (i <= Afinx)) && (((0 <= j) && (j <= Afiny)) || ((y <= j) &&(j <= Dfiny))))
2509  {
2510  Found= NULL;
2511  }
2512  if (((x <= i) && (i <= Dfinx)) && (((0 <= j) && (j <= Afiny)) || ((y <= j) &&(j <= Dfiny))))
2513  {
2514  Found= NULL;
2515  }
2516  }
2517  }
2518  }
2519  if (territory == false) Found=NULL;
2520  } while ((Found==NULL) && (size>0));
2521  return Found;
2522  }
static CfgInt cfg_MateRadius("FEMALE_MATE_RADIUS", CFG_CUSTOM, 250)
int GetCurrentStateNo()
Returns the current state number.
Definition: PopulationManager.h:121

References cfg_MateRadius, TALMaSSObject::GetCurrentStateNo(), Population_Manager::GetLiveArraySize(), random(), Population_Manager::SimH, Population_Manager::SimW, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Vole_Base::SupplyTerritorial(), Population_Manager::TheArray, CfgInt::value(), and vob_Male.

◆ FindRandomMale()

Vole_Male * Vole_Population_Manager::FindRandomMale ( )

Returns a pointer to a random male - he does not even have to have a territory

2881 {
2883  Vole_Male* Found=NULL;
2884  TAnimal* Ap;
2885  int size = (int)GetLiveArraySize(vob_Male);
2886  if (size<1) return NULL;
2887  do
2888  {
2889  int test =random(size);
2890  Ap=TheArray[vob_Male][test];
2891  Found=(Vole_Male*)(Ap);
2892  if (Found->GetCurrentStateNo() == -1) Found=NULL; //if not alive
2893  } while ((Found==NULL) && (size>0));
2894  return Found;
2895 }

References TALMaSSObject::GetCurrentStateNo(), Population_Manager::GetLiveArraySize(), random(), Population_Manager::TheArray, and vob_Male.

◆ FindWithinRadiusMale()

Vole_Male * Vole_Population_Manager::FindWithinRadiusMale ( int  p_x,
int  p_y 
)

looks for males within cfg_MateRadius of p_x,p_y and returns a list of all males

2528 {
2531  vector<Vole_Male*> *vbl;
2532  vbl=new vector<Vole_Male*>;
2533 
2534  // as usual there are 4 possibilities of overlap
2535  // First convert centre co-rdinates to square co-ordinates
2536  // To create start x and y values for 'the mate picking area'
2537  int x= (p_x - cfg_MateRadius.value()); // 'left most' x
2538  if (x<0) x+=SimW; // ensure we start within the landscape!
2539  int y= (p_y - cfg_MateRadius.value()); // 'top' y
2540  if (y<0) y+=SimH;
2541  int range_x= (cfg_MateRadius.value()*2); // width of the search area
2542  int range_y= (cfg_MateRadius.value()*2); // hight of the search area
2543 
2544  // create the extent variables - if out of bounds
2545  int xextent0 = x+range_x; // 'right most' x
2546  int yextent0 = y+range_y; // 'lowest'(bottom) y
2547  int xextent1 = (x+range_x)-SimW; // incase we are out of bounds (positive if we are)
2548  int yextent1 = (y+range_y)-SimH;
2549 
2550  // Create the looping variables needed
2551  int Dfinx;
2552  int Dfiny;
2553  int Afinx=0; //unless the finx values for A are changed this stop
2554  int Afiny=0; //the loop from executing
2555  //int Asty=0;
2556 
2557  // Dfinx, Dfiny are the stop x and y values for 'the mate picking area'
2558  // Afinx, Afiny are the 'overlapping area' if 'the mate picking area' goes out off bounds
2559  // Set default at 0 and only changes value if out off bounds
2560 
2561  // Now create the loop values;
2562  // Type A (no overlap with the eastern bound)
2563  if (xextent0<=SimW)
2564  {
2565  //Afinx are not needed
2566  Dfinx=xextent0; // because no overlap with the right most bound
2567  // do we overlap the bottom (lowest y)?
2568  // Type B & D (overlap bottom, no overlap)
2569  if (yextent0>SimH)
2570  {
2571  // Type B (overlap bottom only)
2572  Dfiny=SimH; // stop at the end
2573  Afiny=yextent1; // the overlap with the top because off bounds
2574  }
2575  else Dfiny=yextent0; // if no overlap bottom
2576  }
2577  else
2578  {
2579  // Type A & C eastern bound & overlap bottom
2580  if (yextent0>SimH)
2581  {
2582  // relies on the default start for Afiny, Afinx, Dfinx, Dfiny
2583  Afinx=xextent1; // Afinx gets a value other than 0 = overlapping value
2584  Afiny=yextent1; //
2585  Dfinx=SimW; // Stop at the end
2586  Dfiny=SimH;
2587  }
2588  else
2589  {
2590  // Type C overlap west bound only
2591  //Afiny, Dfinx, Dfiny set by default
2592  Afinx=xextent1;
2593  Dfinx=SimW; // Stop at the end
2594  Dfiny=yextent0;
2595  }
2596  }
2597  Vole_Male* AMale;
2598  Vole_Male* Found=NULL;
2599  Vole_Base* Ap;
2600 
2601  // A Loop
2602  for (int i=0; i<Afinx; i++) // Afinx and y will be 0 if no overlap
2603  {
2604  for (int j=0; j<Afiny; j++)
2605  {
2606  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j)); // Tjeck to see if any voles are at the location
2607  if (Ap)
2608  {
2609  if (Ap->SupplySex()) // male
2610  {
2611  AMale=(Vole_Male*) (Ap) ;
2612  if (AMale->SupplyTerritorial())
2613  {
2614  vbl->push_back(AMale);
2615  }
2616  }
2617  }
2618  }
2619  // C Loop
2620  for (int j=y; j<Dfiny; j++)
2621  {
2622  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j)); // Tjeck to see if any voles are at the location
2623  if (Ap)
2624  {
2625  if (Ap->SupplySex()) // male
2626  {
2627  AMale=(Vole_Male*) (Ap) ;
2628  if (AMale->SupplyTerritorial())
2629  {
2630  vbl->push_back(AMale);
2631  }
2632  }
2633  }
2634  }
2635  }
2636  // D Loop
2637  for (int i=x; i<Dfinx; i++)
2638  {
2639  for (int j=y; j<Dfiny; j++)
2640  {
2641  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j)); // Tjeck to see if any voles are at the location
2642  if (Ap)
2643  {
2644  if (Ap->SupplySex()) // male
2645  {
2646  AMale=(Vole_Male*) (Ap) ;
2647  if (AMale->SupplyTerritorial())
2648  {
2649  vbl->push_back(AMale);
2650  }
2651  }
2652  }
2653  }
2654  // B Loop
2655  for (int j=0; j<Afiny; j++)
2656  {
2657  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j)); // Tjeck to see if any voles are at the location
2658  if (Ap)
2659  {
2660  if (Ap->SupplySex()) // male
2661  {
2662  AMale=(Vole_Male*) (Ap) ;
2663  if (AMale->SupplyTerritorial())
2664  {
2665  vbl->push_back(AMale);
2666  }
2667  }
2668  }
2669  }
2670  }
2671 
2672  int l = (int) vbl->size();
2673  if (l == 0)
2674  {
2675  return Found=NULL;
2676  }
2677  else {
2678 
2679  int i=(random(l));
2680  Found = vbl->at(i);
2681  return Found;
2682  }
2683 }

References cfg_MateRadius, IDMap< a_type >::GetMapValue(), m_VoleMap, random(), Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplySex(), Vole_Base::SupplyTerritorial(), and CfgInt::value().

◆ GeneticsOutputFile()

void Vole_Population_Manager::GeneticsOutputFile ( unsigned  listindex)

Used to output vole genetics at user-defined dates

4060 {
4061  FILE* vfile= fopen ("GeneticsData.txt","a");
4062  Vole_Base* MV;
4063  if (vfile == NULL) {
4064  m_TheLandscape->Warn("Vole_Population_Manager::GeneticsOutputFile","Could Not Open GeneticsData.txt File");
4065  exit(0);
4066  }
4068  int M=m_TheLandscape->SupplyMonth();
4070  unsigned size= (unsigned)GetLiveArraySize(listindex);
4071  unsigned TotalSize = (unsigned)GetLiveArraySize(vob_Male)+ GetLiveArraySize(vob_Female);
4074  fprintf(vfile,"\n");
4075  fprintf(vfile,"%d\t %d\t %d\t %d\t %d\t %d\n", 0,w ,0, h, size, TotalSize);
4076  fprintf(vfile,"\n");
4077  fprintf(vfile,"%s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\n", "Year", "Mo", "Day", "ID", "Sex", "Age", "Birth Yr", "Terr", "Ma", "TotY", "x", "y", "Poly", "Ele", "Vege", "GA", "DA", "Bx", "By", "Bpol", "Bele", "Bveg");
4078  for (unsigned j=0; j<size; j++)
4079  {
4080  MV=dynamic_cast<Vole_Base*>(TheArray[vob_Male][j]);
4081  int x=MV->Supply_m_Location_x();
4082  int y=MV->Supply_m_Location_y();
4083  int poly=m_TheLandscape->SupplyPolyRef(x,y);
4084  int ele=m_TheLandscape->SupplyElementType(poly);
4085  int vegt=m_TheLandscape->SupplyVegType(poly);
4086  int GA=MV->GetGeneticFlag();
4087  int DA=MV->GetDirectFlag();
4088 
4089  unsigned Age=MV->SupplyAge();
4090  int BY=MV->SupplyBirthYear();
4091  int Mature=MV->SupplyMature();
4092  int Terr=MV->SupplyTerritorial();
4093  int TotYoung = 0;
4094 
4095  int BornX=MV->SupplyXBorn();
4096  int BornY=MV->SupplyYBorn();
4097  int BornPoly=MV->SupplyPolyRefBorn();
4098  int BornEle=MV->SupplyElemBorn();
4099  int BornVegt=MV->SupplyVegBorn();
4100  int sex=(int)MV->SupplySex();
4101  int ID=MV->SupplyIDNo();
4102 
4103  fprintf(vfile,"%d\t",Y); //Year
4104  fprintf(vfile,"%d\t",M); // month letter
4105  fprintf(vfile,"%d\t",D);
4106 
4107  fprintf(vfile,"%d\t",ID);
4108  fprintf(vfile,"%d\t",sex); // sex
4109  fprintf(vfile,"%u\t",Age);
4110  fprintf(vfile,"%d\t",BY); //BirthYear
4111  fprintf(vfile,"%d\t",Terr);
4112  fprintf(vfile,"%d\t",Mature);
4113  fprintf(vfile,"%d\t",TotYoung);
4114  fprintf(vfile,"%d\t",x); // coordinate
4115  fprintf(vfile,"%d\t",y); // coordinate
4116  fprintf(vfile,"%d\t",poly); // polygon
4117  fprintf(vfile,"%d\t",ele); // element type
4118  fprintf(vfile,"%d\t",vegt); // vegetation type
4119  fprintf(vfile,"%d\t",GA); // Genetic affected
4120  fprintf(vfile,"%d\t",DA); // Direct affected
4121  fprintf(vfile,"%d\t",BornX); //X-coordinat for birth location
4122  fprintf(vfile,"%d\t",BornY); //Y-coordinat for birth location
4123  fprintf(vfile,"%d\t",BornPoly);
4124  fprintf(vfile,"%d\t",BornEle);
4125  fprintf(vfile,"%d\t",BornVegt);
4126 
4127  for(int i=0; i< 16; i++)
4128  {
4129  for (int jj=0; jj<2; jj++)
4130  {
4131  uint32 allele = MV->SupplyMyAllele(i, jj);
4132  fprintf(vfile,"%u\t",allele);
4133  }
4134  }
4135  fprintf(vfile,"\n");
4136  ID++;
4137  }
4138  fclose(vfile);
4139 }
unsigned int uint32
Definition: ALMaSS_Setup.h:34
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1321
int SupplyMonth(void)
Definition: landscape.h:1601
int SupplyElemBorn()
Definition: vole_all.h:354
int GetDirectFlag()
Definition: vole_all.h:392
int SupplyBirthYear()
Definition: vole_all.h:344
int SupplyVegBorn()
Definition: vole_all.h:358
int SupplyPolyRefBorn()
Definition: vole_all.h:352
bool SupplyMature()
Definition: vole_all.h:366
int GetGeneticFlag()
Definition: vole_all.h:390
uint32 SupplyMyAllele(int i, int j)
Definition: vole_all.h:387

References Vole_Base::GetDirectFlag(), Vole_Base::GetGeneticFlag(), Population_Manager::GetLiveArraySize(), Population_Manager::m_TheLandscape, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Vole_Base::SupplyAge(), Vole_Base::SupplyBirthYear(), Landscape::SupplyDayInYear(), Vole_Base::SupplyElemBorn(), Landscape::SupplyElementType(), Vole_Base::SupplyIDNo(), Vole_Base::SupplyMature(), Landscape::SupplyMonth(), Vole_Base::SupplyMyAllele(), Landscape::SupplyPolyRef(), Vole_Base::SupplyPolyRefBorn(), Vole_Base::SupplySex(), Landscape::SupplySimAreaWidth(), Vole_Base::SupplyTerritorial(), Vole_Base::SupplyVegBorn(), Landscape::SupplyVegType(), Vole_Base::SupplyXBorn(), Vole_Base::SupplyYBorn(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, vob_Female, vob_Male, and Landscape::Warn().

◆ GeneticsResultsOutput()

void Vole_Population_Manager::GeneticsResultsOutput ( FILE *  ofile,
unsigned  listindex 
)
virtual

Output recording the genetic information for each individual in the population of listindex type

Reimplemented from Population_Manager.

4146 {
4147  char month [13] = {'0','J','F','M','A','m','j','u','a','S','O','N','D'};
4148  int ID=0;
4149  int Y=m_TheLandscape->SupplyYear();
4150  int M=m_TheLandscape->SupplyMonth();
4151  unsigned size = (unsigned)GetLiveArraySize(listindex);
4152  if (size>0)
4153  {
4154  if (listindex==0)
4155  {
4156  Vole_Male* MV;
4157  for (unsigned j=0; j<size; j++)
4158  {
4159  MV=dynamic_cast<Vole_Male*>(TheArray[vob_Male][j]);
4160  int x=MV->Supply_m_Location_x();
4161  int y=MV->Supply_m_Location_x();
4162  // Outputs genetic results
4163  // Year \t Month \t sex \t individual code \t XX\tXX\tXX\tXX\tXX\tXX\tXX\tXXn .... 32 loci x 2 alleles
4164  fprintf(ofile,"%d\t",ID);
4165  fprintf(ofile,"M");
4166  fprintf(ofile,"%c",month[M]);
4167  fprintf(ofile,"%d\t",Y);
4168  fprintf(ofile,"%d\t",x);
4169  fprintf(ofile,"%d\t",y);
4170  for (int g=0; g<32; g++)
4171  {
4172  int allele=1+MV->SupplyAllele(g,0);
4173  fprintf(ofile,"%d\t",allele);
4174  allele=1+MV->SupplyAllele(g,1);
4175  fprintf(ofile,"%d\t",allele);
4176  }
4177  fprintf(ofile,"\n");
4178  ID++;
4179  }
4180  }
4181  else
4182  {
4183  Vole_Female* FV;
4184  for (unsigned j=0; j<size; j++)
4185  {
4186  FV=dynamic_cast<Vole_Female*>(TheArray[vob_Female][j]);
4187  int x=FV->Supply_m_Location_x();
4188  int y=FV->Supply_m_Location_x();
4189  // Outputs genetic results
4190  // Year \t Month \t sex \t individual code \t XX\tXX\tXX\tXX\tXX\tXX\tXX\tXXn .... 32 loci x 2 alleles
4191  fprintf(ofile,"%d\t",ID);
4192  fprintf(ofile,"F");
4193  fprintf(ofile,"%c",month[M]);
4194  fprintf(ofile,"%d\t",Y);
4195  fprintf(ofile,"%d\t",x);
4196  fprintf(ofile,"%d\t",y);
4197  for (int g=0; g<32; g++)
4198  {
4199  int allele=1+FV->SupplyAllele(g,0);
4200  fprintf(ofile,"%d\t",allele);
4201  allele=1+FV->SupplyAllele(g,1);
4202  fprintf(ofile,"%d\t",allele);
4203  }
4204  fprintf(ofile,"\n");
4205  ID++;
4206  }
4207  }
4208  }
4209 }
int SupplyYear(void)
Definition: landscape.h:1611

References Population_Manager::GetLiveArraySize(), Population_Manager::m_TheLandscape, TAnimal::Supply_m_Location_x(), Vole_Base::SupplyAllele(), Landscape::SupplyMonth(), Landscape::SupplyYear(), Population_Manager::TheArray, vob_Female, and vob_Male.

◆ GetHabitatQuality()

double Vole_Population_Manager::GetHabitatQuality ( int  a_index)
inline

◆ GetVoleAllele()

uint32 Vole_Population_Manager::GetVoleAllele ( int  a_list,
int  a_vole,
int  a_locus,
int  a_chromosome 
)
inline

used to get a specific vole allele from outside the population manager

201  {
202  Vole_Base* new_VB;
203  new_VB = dynamic_cast<Vole_Base *>(TheArray[a_list][a_vole]);
204  return new_VB->SupplyMyAllele(a_locus, a_chromosome);
205  }

References Vole_Base::SupplyMyAllele(), and Population_Manager::TheArray.

◆ ImpactedProbe()

void Vole_Population_Manager::ImpactedProbe ( )
virtual

use for pesticide simulations only to determine the number of individual males currently impacted by pesticide Added April 2006

Reimplemented from Population_Manager.

523  {
524  FILE* MyFile;
525  MyFile=fopen("VoleImpactedProbe.txt","a");
526  if (MyFile == NULL){
527  m_TheLandscape->Warn("Vole_Population_Manager::ImpactedProbe","Could Not Open VoleImpactedProbe.txt File");
528  exit(0);
529  }
530  // This just needs to trawl through the males and to count how many are affected by
531  // a pesticide. This function needs to be redefined for every new pesticide case
532  // Current implementation is for Trine Dalkvists 'vinclozolin' work
533  int dno=0;
534  int gno=0;
535  Vole_Male* vm;
536  unsigned size=(unsigned)GetLiveArraySize(vob_Male);
537  for (unsigned j=0; j<size; j++) {
538  vm=dynamic_cast<Vole_Male*>(TheArray[vob_Male][j]);
539  if (vm->GetGeneticFlag()!=0) gno++;
540  if (vm->GetDirectFlag()!=0) dno++;
541  }
542  int tno=size;
543  fprintf(MyFile,"%d\t%d\t%d\n",tno,dno,gno);
544  fclose(MyFile);
545 
546 }

References Vole_Base::GetDirectFlag(), Vole_Base::GetGeneticFlag(), Population_Manager::GetLiveArraySize(), Population_Manager::m_TheLandscape, Population_Manager::TheArray, vob_Male, and Landscape::Warn().

◆ Init()

void Vole_Population_Manager::Init ( void  )
virtual

autom. called by constructor.
Sets up output files and creates initial population

246 {
251  // Need to resize out vole habitat qualities vector to the correct size for the number of polygons
252  // NB IF the landscape were to change the number of polygons due to morphing (not implemented currently), then
253  // this code is broken.
254  unsigned int p = m_TheLandscape->SupplyNumberOfPolygons();
255  VoleHabitatBaseQualities.resize(p);
257  //m_TheLandscape->ResetAllVoleGrazing();
258  // Set up output files
260  {
261  ofstream ofile("VoleLandscapeGridData.txt",ios::out);
262  ofile.close();
263  }
264  if ( cfg_RipleysOutput_used.value() ) {
266  }
269  } else ReallyBigOutputPrb=0;
271  FILE* GFile = fopen("VoleGeneticsOutput.txt", "w" );
272  if ( !GFile ) {
273  g_msg->Warn( WARN_FILE, "Population_Manager::Init(): ""Unable to open VoleGeneticsOutput.txt","");
274  exit( 1 );
275  }
277  {
278  m_VoleAgeSexLocationFile = new ofstream("VoleAgeSexLocation.txt", ios::out);
279  }
280  // Pass some parameters to member variables (speed optimisation)
285  //m_BaseVoleDensity = 1/(cfg_MinFemaleTerritorySize.value() * 4.0) * cfg_VoleDDepConst.value();
289 #ifdef __VOLEPESTICIDEON
291  m_impacted = 0;
292  m_notimpacted = 0;
293  m_geneticimpacted = 0;
294  m_LittersLost = 0;
295  m_LittersProduced = 0;
296  FILE* impf;
297  impf = fopen("Impacted.res","w");
298  if (!impf) {
299  m_TheLandscape->Warn("Vole_Population_Manager Destructor","Could Not Open Impacted.Res File");
300  exit(0);
301  }
302  fclose(impf);
303 #endif
304  /*
305  Create probabilities for ReproTable
306 
307  ReproTable is two years each with 12 numbers representing the minimum litter size in the 0,1 position and in 2,3 positions then it is the number out of 100 that have one more than the first number\n
308  Currently this is set to no variation and litter sizes follow Andrea (1981).
309  */
310  for (int i = 0; i < 12; i++)
311  {
312  ReproTable[0][i] = (int)floor(ReproTable_base[0][i]);
313  ReproTable[2][i] = (int)floor(0.5+(ReproTable_base[0][i]*100)-(ReproTable[0][i]*100));
314  ReproTable[1][i] = (int)floor(ReproTable_base[1][i]);
315  ReproTable[3][i] = (int)floor(0.5+(ReproTable_base[1][i]*100)-(ReproTable[1][i]*100));
316  }
317  strcpy(m_SimulationName,"Field Vole");
318  // Create males and females
319  struct_Vole_Adult* av;
320  av = new struct_Vole_Adult;
321  av->VPM = this;
322  av->L = m_TheLandscape;
324  g_MaxAllele = (unsigned char) cfg_MaxAllele.value();
325 
326  GeneticMaterial AGene;
327  for (int i=0; i<cfg_vole_starting_numberM.value(); i++) //Initial creation of males
328  {
329  AGene.Initiation(AFreq);
330  if (m_TheLandscape->SupplyPesticideType() !=-1) // No big time penalty here, so we use this rather than the #ifdef
331  {
332  // If any pesticide is being used then we assume genetics is only used to control this - so make sure there is no
333  // pesticide influenced genetetic code set (ie put a zero in 0 allele, of both chromosomes
335  {
336  if (g_rand_uni()< cfg_ResistanceStartFrequency.value()) AGene.SetAllele(3,1,0); else AGene.SetAllele(3,0,0);
337  if (g_rand_uni()< cfg_ResistanceStartFrequency.value()) AGene.SetAllele(3,1,1); else AGene.SetAllele(3,0,1);
338  }
339  AGene.SetAllele(0,0,0);
340  AGene.SetAllele(0,0,1);
341  }
342  av->Genes=AGene;
343  bool found = false;
344  while (!found)
345  {
346  av->x = random(SimW);
347  av->y = random(SimH);
348  found = SuitableStartingLocation(av->x, av->y);
349  }
350  CreateObjects_Init(vob_Male,NULL,av,1);
351  }
352 
353  for (int i=0; i<cfg_vole_starting_numberF.value(); i++) //initial creation of females
354  {
355  AGene.Initiation(AFreq);
356  if (m_TheLandscape->SupplyPesticideType() !=-1) // No big time penalty here, so we use this rather than the #ifdef
357  {
358  // If any pesticide is being used then we assume genetics is only used to control this - so make sure there is no
359  // pesticide influenced genetetic code set (ie put a zero in 0 allele, of both chromosomes
361  {
362  if (g_rand_uni()< cfg_ResistanceStartFrequency.value()) AGene.SetAllele(3,1,0); else AGene.SetAllele(3,0,0);
363  if (g_rand_uni()< cfg_ResistanceStartFrequency.value()) AGene.SetAllele(3,1,1); else AGene.SetAllele(3,0,1);
364  }
365  AGene.SetAllele(0,0,0);
366  AGene.SetAllele(0,0,1);
367  }
368  av->Genes=AGene; // Their genes are set based on the Initiation (AlFreq) function
369  bool found = false;
370  while (!found)
371  {
372  av->x = random(SimW);
373  av->y = random(SimH);
374  found = SuitableStartingLocation(av->x, av->y);
375  }
376  CreateObjects_Init(vob_Female,NULL,av,1);
377  }
378  delete av;
379 
380 
381  // Load List of Animal Classes
382  m_ListNames[0] = "Juvenile Male";
383  m_ListNames[1] = "Juvenile Female";
384  m_ListNames[2] = "Male";
385  m_ListNames[3] = "Female";
386  m_ListNameLength = 4;
388 
389  // Set up before step action sorts
390  // sort w.r.t. x
391  BeforeStepActions[0] = 0; // SortXIndex
392  BeforeStepActions[1] = 0; // SortXIndex
393 
394  // Load State Names
395  StateNames[tovs_InitialState] = "Initial State";
396  //Males
397  StateNames[tovs_JuvenileExploration] = "Juvenile Exploration";
398  StateNames[tovs_MMaturation] = "Maturation";
399  StateNames[tovs_MEvaluateExplore] = "Evaluate & Explore";
400  StateNames[tovs_Infanticide] = "Infanticide";
401  StateNames[tovs_MDying] = "Dying";
402  //Females
403  StateNames[tovs_FEvaluateExplore] = "Evaluate & Explore";
404  StateNames[tovs_ReproBehaviour] = "Repro. Behaviour";
405  StateNames[tovs_Lactating] = "Lactating";
406  StateNames[tovs_GiveBirth] = "Give Birth";
407  StateNames[tovs_FMaturation] = "Maturation";
408  StateNames[tovs_Mating] = "Mating";
409  StateNames[tovs_UpdateGestation] = "Update Gestation";
410  StateNames[tovs_SpecialExplore] = "Special Explore";
411  StateNames[tovs_FDying] = "Dying";
412 
414  // OPEN THE TEST FILES _ THIS CODE CAN BE COMMENTED OUT IF THEY ARE NOT NEEDED - TODO TIDY THIS UP
415  TestFile = fopen("TestFile.Txt", "w" );
416  if (!TestFile) {
417  m_TheLandscape->Warn("Population_Manager::Population_Manager -", "Could Not Open TestFile.txt");
418  exit(0);
419  }
420  TestFile2 = fopen("TestFile2.Txt", "w" );
421  m_StepSize = 1440; // Default - it is up to the individual animal models to
422  if (!TestFile2) {
423  m_TheLandscape->Warn("Population_Manager::Population_Manager -", "Could Not Open TestFile2.txt");
424  exit(0);
425  }
426 #ifdef __VOLEPESTICIDEON
430  m_geneticsterilitychance = cfg_geneticsterilitychance.value();
432  m_f1sterilitychance = cfg_f1sterilitychance.value();
433 // Other output files
434 #endif
435  char Nme[ 511 ];
436  strcpy( Nme, "GeneticsOutput.txt" );
437  m_GeneticsFile = fopen( Nme, "w" );
438  strcpy( Nme, "AlleleFreqs.txt" );
439  m_AlleleFreqsFile = fopen( Nme, "w" );
440  strcpy( Nme, "forEASYPOP.txt" );
441  m_EasyPopRes = fopen( Nme, "w" );
442 
443  // Vole traplines set-up
444  if (cfg_UseVoleTraplines.value()) {
446  }
447  // Vole record mortality set-up
448  if (cfg_RecordVoleMort.value()) {
449  // The two ints in the constructor call refer to the number of int data and double data used respectively
450  // The output will print ints first then doubles
452  // In the string output allows us to provide titles:
453  m_VoleRecordMort->OPrint("Year\tDay\tMStarve\tFStarve\tMBck\tFBck\tMFarm\tFFarm\tMDisp\tFDisp\tMPred\tFPred\tMLife\tFLife\tMPest\tFPest\t");
455  }
457  }
@ TOP_Vole
Definition: PopulationManager.h:61
CfgInt cfg_MinReproAgeM
double MutationChance
Definition: GeneticMaterial.cpp:52
static CfgStr cfg_VoleRecordMortFile("VOLE_RECORDMORTFILE", CFG_CUSTOM, "VoleMortalityCauses.txt")
static CfgFloat cfg_VoleFemaleMove("VOLE_FEMALEMOVE", CFG_CUSTOM, 0.0505)
const float ReproTable_base[2][12]
Definition: VolePopulationManager.cpp:171
static CfgInt cfg_geneticproductfertilityeffect("VOLE_GENETICPRODUCTFERTILITYEFFECT", CFG_CUSTOM, 50)
static CfgFloat cfg_f1sterilitychance("VOLE_FONESTERILITYCHANCE", CFG_CUSTOM, 0.0)
CfgInt cfg_MinReproAgeF
static CfgFloat cfg_ResistanceStartFrequency("VOLE_RESISTANCESTARTFREQ", CFG_CUSTOM, 0.01)
int MinReproAgeF
Definition: Vole_all.cpp:147
int g_sigAgeDiff
Definition: Vole_all.cpp:153
unsigned char g_MaxAllele
Definition: GeneticMaterial.cpp:53
double MoveToLessFavourable
Definition: VolePopulationManager.cpp:157
static CfgInt cfg_vole_reprofinishdate("VOLE_REPROFINISHDATE", CFG_CUSTOM, 243)
CfgBool cfg_ReallyBigOutput_used
static CfgFloat cfg_geneticsterilitychance("VOLE_GENETICSTERILITYCHANCE", CFG_CUSTOM, 0)
int MinReproAgeM
Definition: Vole_all.cpp:145
static CfgStr cfg_VoleTraplinesfile("VOLE_TRAPLINESFILE", CFG_CUSTOM, "VoleTraplines.txt")
static CfgFloat cfg_MutationChance("GENETICS_MUTATION_CHANCE", CFG_CUSTOM, 0.001)
static CfgFloat cfg_MoveToLessFavourable("VOLEMOVETOLESSFAVOURALBLE", CFG_CUSTOM, 0.005)
static CfgInt cfg_MaxAllele("GENETICS_MAXALLELE", CFG_CUSTOM, 255)
static CfgInt cfg_vole_starting_numberM("VOLE_START_NO_M", CFG_CUSTOM, 5000)
static CfgInt cfg_vole_starting_numberF("VOLE_START_NO_F", CFG_CUSTOM, 5000)
CfgBool cfg_RipleysOutput_used
double g_NoFemalesMove
Definition: Vole_all.cpp:205
static CfgInt cfg_sigAgeDiff("VOLE_SIGAGEDIFF", CFG_CUSTOM, 30)
static CfgBool cfg_voleLandscapeGridOutputUsed("VOLE_LANDSCAPEGRIDOUTPUTUSED", CFG_CUSTOM, true)
static CfgInt cfg_VoleTrapResolution("VOLE_TRAPRESOLUTION", CFG_CUSTOM, 2)
const char * value(void)
Definition: configurator.h:152
Class for the genetic material optionally carried by animals in ALMaSS.
Definition: GeneticMaterial.h:95
void SetAllele(int pos, uint32 value, int Chromosome)
Definition: GeneticMaterial.cpp:196
void Initiation(AlleleFreq *Al)
Definition: GeneticMaterial.cpp:366
TTypesOfPesticide SupplyPesticideType(void)
Definition: landscape.h:433
FILE * ReallyBigOutputPrb
Definition: PopulationManager.h:595
const char * m_ListNames[32]
Definition: PopulationManager.h:537
char m_SimulationName[255]
Definition: PopulationManager.h:513
unsigned BeforeStepActions[12]
Definition: PopulationManager.h:542
FILE * TestFile
Definition: PopulationManager.h:539
const char * StateNames[100]
Definition: PopulationManager.h:531
bool OpenTheRipleysOutputProbe(string a_NWordFilename)
Definition: PopulationManager.cpp:757
unsigned m_ListNameLength
Definition: PopulationManager.h:538
int m_StepSize
Definition: PopulationManager.h:533
FILE * TestFile2
Definition: PopulationManager.h:540
TTypesOfPopulation m_population_type
Definition: PopulationManager.h:580
bool OpenTheReallyBigProbe()
Definition: PopulationManager.cpp:859
A class for simulation virtual traplines.
Definition: VolePopulationManager.h:95
int m_geneticproductfertilityeffect
Definition: VolePopulationManager.h:285
void CreateObjects_Init(VoleObject ob_type, TAnimal *pvo, struct_Vole_Adult *as, int number)
Definition: VolePopulationManager.cpp:3588
ofstream * m_VoleAgeSexLocationFile
Definition: VolePopulationManager.h:194
bool OpenSexRatiosProbe()
Definition: VolePopulationManager.cpp:3890
int ReproTable[4][12]
Definition: VolePopulationManager.h:221
void OpenResistanceOutput()
Opens the output file ready for resistance results.
Definition: VolePopulationManager.cpp:4212
bool SuitableStartingLocation(int a_x, int a_y)
Definition: VolePopulationManager.cpp:460
A base class for summary outputs.
Definition: VolePopulationManager.h:123
virtual void OPrintEndl()
Definition: VolePopulationManager.cpp:4030
GeneticMaterial Genes
Definition: vole_all.h:141
Vole_Population_Manager * VPM
Definition: vole_all.h:139
Landscape * L
Definition: vole_all.h:138
@ WARN_FILE
Definition: maperrormsg.h:37
@ tovs_ReproBehaviour
Definition: vole_all.h:66
@ tovs_JuvenileExploration
Definition: vole_all.h:59
@ tovs_Lactating
Definition: vole_all.h:67
@ tovs_Infanticide
Definition: vole_all.h:62
@ tovs_SpecialExplore
Definition: vole_all.h:72
@ tovs_FMaturation
Definition: vole_all.h:69
@ tovs_Mating
Definition: vole_all.h:70
@ tovs_UpdateGestation
Definition: vole_all.h:71
@ tovs_GiveBirth
Definition: vole_all.h:68
@ tovs_MMaturation
Definition: vole_all.h:60
@ tovs_FEvaluateExplore
Definition: vole_all.h:65
@ tovs_InitialState
Definition: vole_all.h:57
@ tovs_MEvaluateExplore
Definition: vole_all.h:61

References AFreq, Population_Manager::BeforeStepActions, cfg_extradispmort, cfg_f1sterilitychance, cfg_geneticproductfertilityeffect, cfg_geneticsterilitychance, cfg_MaxAllele, cfg_MinReproAgeF, cfg_MinReproAgeM, cfg_MoveToLessFavourable, cfg_MutationChance, cfg_ReallyBigOutput_used, cfg_RecordVoleMort, cfg_ResistanceStartFrequency, cfg_RipleysOutput_used, cfg_SexRatiosOutput_used, cfg_sigAgeDiff, cfg_useagesexlocation, cfg_UseVoleTraplines, cfg_vole_reprofinishdate, cfg_vole_starting_numberF, cfg_vole_starting_numberM, cfg_VoleBackgroundMort, cfg_VoleFemaleMove, cfg_voleLandscapeGridOutputUsed, cfg_VoleRecordMortFile, cfg_VoleTraplinesfile, cfg_VoleTrapResolution, cfg_VoleUseResistanceOuput, CreateObjects_Init(), g_DailyMortChance, g_extradispmort, g_MaleReproductFinish, g_MaxAllele, g_msg, g_NoFemalesMove, g_rand_uni, g_sigAgeDiff, struct_Vole_Adult::Genes, GeneticMaterial::Initiation(), struct_Vole_Adult::L, Population_Manager::m_AlleleFreqsFile, Population_Manager::m_EasyPopRes, m_geneticproductfertilityeffect, Population_Manager::m_GeneticsFile, Population_Manager::m_ListNameLength, Population_Manager::m_ListNames, Population_Manager::m_population_type, Population_Manager::m_SimulationName, Population_Manager::m_StepSize, Population_Manager::m_TheLandscape, m_Traplines, m_VoleAgeSexLocationFile, m_VoleRecordMort, MinReproAgeF, MinReproAgeM, MoveToLessFavourable, MutationChance, OpenResistanceOutput(), OpenSexRatiosProbe(), Population_Manager::OpenTheReallyBigProbe(), Population_Manager::OpenTheRipleysOutputProbe(), VoleSummaryOutput::OPrint(), VoleSummaryOutput::OPrintEndl(), random(), Population_Manager::ReallyBigOutputPrb, ReproTable, ReproTable_base, GeneticMaterial::SetAllele(), Population_Manager::SimH, Population_Manager::SimW, Population_Manager::StateNames, SuitableStartingLocation(), Landscape::SupplyNumberOfPolygons(), Landscape::SupplyPesticideType(), Population_Manager::TestFile, Population_Manager::TestFile2, TOP_Vole, tovs_FDying, tovs_FEvaluateExplore, tovs_FMaturation, tovs_GiveBirth, tovs_Infanticide, tovs_InitialState, tovs_JuvenileExploration, tovs_Lactating, tovs_Mating, tovs_MDying, tovs_MEvaluateExplore, tovs_MMaturation, tovs_ReproBehaviour, tovs_SpecialExplore, tovs_UpdateGestation, CfgInt::value(), CfgFloat::value(), CfgBool::value(), CfgStr::value(), vob_Female, vob_Male, VoleHabitatBaseQualities, struct_Vole_Adult::VPM, MapErrorMsg::Warn(), Landscape::Warn(), WARN_FILE, struct_Vole_Adult::x, and struct_Vole_Adult::y.

Referenced by Vole_Population_Manager().

◆ InSquare()

bool Vole_Population_Manager::InSquare ( int  p_x,
int  p_y,
int  p_sqx,
int  p_sqy,
int  p_range 
)

Determines if p_x,p_y is the in the square denoted by p_sqx,p_sqy + p_range

3232 {
3235  int x_extent = p_sqx+p_range;
3236  int y_extent = p_sqy+p_range;
3237  if (x_extent >= SimW)
3238  {
3239  if (y_extent >= SimH) // overlaps TR corner of sim area
3240  // Must test four rectangles
3241  /*
3242  1) p_sqx to <SimW, p_sq_y to SimW (TR)
3243  2) 0 to x_extent-SimW p_sq_y to SimH (TL)
3244  3) 0 to x_extent-SimW, 0 to y_extent-SimH (BL)
3245  4) p_sq_x to <SimW, 0 to y_extent-SimH (BR)
3246  */
3247  {
3248  // 1 Top right square (limited by SimAreaHeight & SimAreaWidth
3249  if ((p_x >=p_sqx) && (p_y >=p_sqy)) return true;
3250  // 2 Top Left Square (limited by 0,SimAreaHeight)
3251  if ((p_x <x_extent-SimW)&& (p_y>p_sqy)) return true;
3252  // 3 Bottom Left square (limited by 0,0)
3253  if ((p_x <x_extent-SimW)&&(p_y<y_extent-SimH)) return true;
3254  // Bottom Right square (limited by SimAreaWidth,0)
3255  if ((p_x >=p_sqx)&& (p_y<y_extent-SimH)) return true;
3256 
3257  }
3258  else // Overlaps the west edge of the sim area
3259  {
3260  if ((p_y >=p_sqy) && (p_y<y_extent))
3261  { // y is in square
3262  if (p_x >=p_sqx) return true;
3263  else if (p_x <x_extent-SimW) return true;
3264  }
3265  }
3266  }
3267  else
3268  {
3269  if (y_extent >= SimH) // overlaps top of simulation area
3270  {
3271  if ((p_x >=p_sqx) && (p_x<x_extent))
3272  {
3273  // x is OK
3274  if (p_y >=p_sqy) return true;
3275  else if (p_y<y_extent-SimH) return true;
3276  }
3277  }
3278  else // square does not overlap end of simulation area
3279  {
3280  if ((p_x >=p_sqx) && (p_x<x_extent) &&
3281  (p_y >=p_sqy) && (p_y<y_extent)) return true;
3282  }
3283  }
3284  return false; // not in square
3285 }

References Population_Manager::SimH, and Population_Manager::SimW.

◆ IsTrap()

bool Vole_Population_Manager::IsTrap ( int  p_x,
int  p_y 
)
inline
207 { m_TheLandscape->CorrectCoords(p_x,p_y); return m_Traplines->IsTrap(p_x, p_y); };
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1535
bool IsTrap(unsigned a_x, unsigned a_y)
Is there a trap at this x,y?
Definition: VolePopulationManager.h:102

References Landscape::CorrectCoords(), TrapLineMap::IsTrap(), Population_Manager::m_TheLandscape, and m_Traplines.

Referenced by Vole_Base::CheckTraps().

◆ LandscapeQuadrantOutputProbe()

void Vole_Population_Manager::LandscapeQuadrantOutputProbe ( int  a_day)
virtual

Output file facility added in January 2013

This output splits the landscape up into 16x16 cells which gives landscapes of 625x625m grids for 10x10 km.
All voles are counted in the landspape and assigned to a grid. The sum of all individials in the grid is then output to the output file separated by tabs and prefixed by the global simulation day.
NB this only works for square landscapes.

3699 {
3701  TAnimal* VB;
3702  unsigned int totalYM, totalYF, totalAM, totalAF;
3703  int gridcount[256];
3709  int width = m_TheLandscape->SupplySimAreaWidth();
3710  for (int i=0; i<256; i++) gridcount[i] = 0;
3711  double sqwidth = width/16.0;
3712  totalYM= (unsigned int)GetLiveArraySize(vob_JuvenileMale);
3713  for (unsigned j=0; j<totalYM; j++) //juvenile males
3714  {
3715  VB=TheArray[vob_JuvenileMale][j];
3716  int gx= (int) floor(VB->Supply_m_Location_x()/sqwidth);
3717  int gy= (int) floor(VB->Supply_m_Location_y()/sqwidth);
3718  gridcount[gx+gy*16]++;
3719  }
3720  totalYF= (unsigned int) GetLiveArraySize(vob_JuvenileFemale);
3721  for (unsigned j=0; j<totalYF; j++) //juvenile females
3722  {
3724  int gx= (int) floor(VB->Supply_m_Location_x()/sqwidth);
3725  int gy= (int) floor(VB->Supply_m_Location_y()/sqwidth);
3726  gridcount[gx+gy*16]++;
3727  }
3728  totalAM= (unsigned int) GetLiveArraySize(vob_Male);
3729  for (unsigned j=0; j<totalAM; j++) //adult males
3730  {
3731  VB=TheArray[vob_Male][j];
3732  int gx= (int) floor(VB->Supply_m_Location_x()/sqwidth);
3733  int gy= (int) floor(VB->Supply_m_Location_y()/sqwidth);
3734  gridcount[gx+gy*16]++;
3735  }
3736  totalAF= (unsigned int) GetLiveArraySize(vob_Female);
3737  for (unsigned j=0; j<totalAF; j++) //adult females
3738  {
3739  VB=TheArray[vob_Female][j];
3740  int gx= (int) floor(VB->Supply_m_Location_x()/sqwidth);
3741  int gy= (int) floor(VB->Supply_m_Location_y()/sqwidth);
3742  gridcount[gx+gy*16]++;
3743  }
3744  // Do the output
3745  /* Open the output file and append */
3746  ofstream ofile("VoleLandscapeGridData.txt",ios::app);
3747  ofile << a_day << '\t' << totalYM << '\t' << totalYF << '\t' << totalAM << '\t' << totalAF<< '\t';
3748  for (int i=0; i<255; i++)
3749  {
3750  ofile << gridcount[i] << '\t';
3751  }
3752  ofile << gridcount[255] << endl;
3753  ofile.close();
3754 
3755 }

References Population_Manager::GetLiveArraySize(), Population_Manager::m_TheLandscape, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Landscape::SupplySimAreaWidth(), Population_Manager::TheArray, vob_Female, vob_JuvenileFemale, vob_JuvenileMale, and vob_Male.

Referenced by DoFirst().

◆ ListClosestFemales()

int Vole_Population_Manager::ListClosestFemales ( int  p_x,
int  p_y,
int  p_steps 
)

Lists all females within p_steps of p_x & p_y and returns the number in the list

2079 {
2080  // First clear the FemaleVoleList
2081  FList.clear();
2082  // looks for a female within p_Steps of p_x,p_y
2083  // as usual there are 4 possibilities of overlap
2084  // First convert centre co-ordinates to square co-ordinates
2085 
2086  int x=p_x - p_steps;
2087  if (x<0) x+=SimW; // ensure we start in the simulation area!
2088  int y=p_y - p_steps;
2089  if (y<0) y+=SimH;
2090  int range_x=p_steps*2;
2091  int range_y=p_steps*2;
2092 
2093  // create the extent variables
2094  int xextent0 = x+range_x;
2095  int yextent0 = y+range_y;
2096  int xextent1 = (x+range_x)-SimW;
2097  int yextent1 = (y+range_y)-SimH;
2098  // Create the looping variables needed
2099  // Create the looping variables needed
2100  int Dfinx;
2101  int Dfiny;
2102  int Afinx=0; //unless the finx values for A are changed this stop
2103  int Afiny=0; //the loop from executing
2104  int Asty=0;
2105  // int Astx,Dstx,Dtsy are always default so variables not used from them
2106  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
2107  // Dsty is always y, Afiny is always yextent1 if it is used
2108  // Now create the loop values;
2109  if (xextent0<=SimW) // No overlap with the eastern side
2110  {
2111  // Dstx, Dsty, Asty set by defaults
2112  //Astx & Afinx are not needed
2113  Dfinx=xextent0;
2114  // do we overlap the bottom?
2115  // Type B & D (overlap bottom, no overlap)
2116  if (yextent0>SimH)
2117  {
2118  // Type B (overlap bottom only)
2119  Dfiny=SimH; // stop at the end
2120  Afiny=yextent1; // the overlap with the top
2121  }
2122  else Dfiny=yextent0;
2123  }
2124  else
2125  {
2126  // Type A & C overlap bottom & eastern edgdes
2127  if (yextent0>SimH)
2128  {
2129  // relies on the default start for Asty, Astx, Dstx, Dsty
2130  Afinx=xextent1;
2131  Afiny=yextent1;
2132  Dfinx=SimW; // Stop at the end
2133  Dfiny=SimH;
2134  }
2135  else
2136  {
2137  // Type C overlap left edge only
2138  // Astx & Afiny are not needed here
2139  //Astx, Dstx, Dsty set by default
2140  Afinx=xextent1;
2141  Dfinx=SimW; // Stop at the end
2142  Dfiny=yextent0;
2143  }
2144  }
2145  Vole_Female* AFemale;
2146  Vole_Base* Ap;
2147  int NoFound=0;
2148 
2149  // A Loop
2150  for (int i=0; i<Afinx; i++)
2151  {
2152  for (int j=Asty; j<Afiny; j++)
2153  {
2154  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2155  if (Ap)
2156  {
2157  if (!Ap->SupplySex()) // female
2158  {
2159  AFemale=(Vole_Female*) (Ap) ;
2160  if (AFemale->SupplyTerritorial())
2161  {
2162  FList.push_back(AFemale);
2163  NoFound++;
2164  }
2165  }
2166  }
2167  }
2168  // C Loop
2169  for (int j=y; j<Dfiny; j++)
2170  {
2171  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2172  if (Ap)
2173  {
2174  if (!Ap->SupplySex()) // female
2175  {
2176  AFemale=(Vole_Female*) (Ap) ;
2177  if (AFemale->SupplyTerritorial())
2178  {
2179  FList.push_back(AFemale);
2180  NoFound++;
2181  }
2182  }
2183  }
2184  }
2185  }
2186  // D Loop
2187  for (int i=x; i<Dfinx; i++)
2188  {
2189  for (int j=y; j<Dfiny; j++)
2190  {
2191  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2192  if (Ap)
2193  {
2194  if (!Ap->SupplySex()) // female
2195  {
2196  AFemale=(Vole_Female*) (Ap) ;
2197  if (AFemale->SupplyTerritorial())
2198  {
2199  FList.push_back(AFemale);
2200  NoFound++;
2201  }
2202  }
2203  }
2204  }
2205  // B Loop
2206  for (int j=0; j<Afiny; j++)
2207  {
2208  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2209  if (Ap)
2210  {
2211  if (!Ap->SupplySex()) // female
2212  {
2213  AFemale=(Vole_Female*) (Ap) ;
2214  if (AFemale->SupplyTerritorial())
2215  {
2216  FList.push_back(AFemale);
2217  NoFound++;
2218  }
2219  }
2220  }
2221  }
2222  }
2223  return NoFound;
2224 }
Vole_FemaleList FList
Definition: VolePopulationManager.h:224

References FList, IDMap< a_type >::GetMapValue(), m_VoleMap, Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplySex(), and Vole_Base::SupplyTerritorial().

◆ ListClosestMales()

int Vole_Population_Manager::ListClosestMales ( int  p_x,
int  p_y,
int  p_steps 
)

Looks for males within p_Steps of p_x,p_y and returns the number of them. Pointers to these are saved in MList

1929 {
1930  // First clear the MaleVoleList
1931  MList.clear();
1932 
1933  // as usual there are 4 possibilities of overlap
1934  // First convert centre co-rdinates to square co-ordinates
1935 
1936  int x=p_x - p_steps;
1937  if (x<0) x+=SimW; // ensure we start in the simulation area!
1938  int y=p_y - p_steps;
1939  if (y<0) y+=SimH;
1940  int range_x=p_steps*2;
1941  int range_y=p_steps*2;
1942 
1943  // create the extent variables
1944  int xextent0 = x+range_x;
1945  int yextent0 = y+range_y;
1946  int xextent1 = (x+range_x)-SimW;
1947  int yextent1 = (y+range_y)-SimH;
1948  // Create the looping variables needed
1949  // Create the looping variables needed
1950  int Dfinx;
1951  int Dfiny;
1952  int Afinx=0; //unless the finx values for A are changed this stop
1953  int Afiny=0; //the loop from executing
1954  int Asty=0;
1955  // int Astx,Dstx,Dtsy are always default so variables not used from them
1956  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
1957  // Dsty is always y, Afiny is always yextent1 if it is used
1958  // Now create the loop values;
1959  if (xextent0<=SimW) // No overlap with the eastern side
1960  {
1961  // Dstx, Dsty, Asty set by defaults
1962  //Astx & Afinx are not needed
1963  Dfinx=xextent0;
1964  // do we overlap the bottom?
1965  // Type B & D (overlap bottom, no overlap)
1966  if (yextent0>SimH)
1967  {
1968  // Type B (overlap bottom only)
1969  Dfiny=SimH; // stop at the end
1970  Afiny=yextent1; // the overlap with the top
1971  }
1972  else Dfiny=yextent0;
1973  }
1974  else
1975  {
1976  // Type A & C overlap bottom & eastern edgdes
1977  if (yextent0>SimH)
1978  {
1979  // relies on the default start for Asty, Astx, Dstx, Dsty
1980  Afinx=xextent1;
1981  Afiny=yextent1;
1982  Dfinx=SimW; // Stop at the end
1983  Dfiny=SimH;
1984  }
1985  else
1986  {
1987  // Type C overlap left edge only
1988  // Astx & Afiny are not needed here
1989  //Astx, Dstx, Dsty set by default
1990  Afinx=xextent1;
1991  Dfinx=SimW; // Stop at the end
1992  Dfiny=yextent0;
1993  }
1994  }
1995  Vole_Base* Ap;
1996  Vole_Male* AMale;
1997  int NoFound=0;
1998 
1999  // A Loop
2000  for (int i=0; i<Afinx; i++)
2001  {
2002  for (int j=Asty; j<Afiny; j++)
2003  {
2004  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2005  if (Ap)
2006  {
2007  if (Ap->SupplySex()) // male
2008  {
2009  AMale=(Vole_Male*) Ap;
2010  if (AMale->SupplyTerritorial())
2011  {
2012  MList.push_back(AMale);
2013  NoFound++;
2014  }
2015  }
2016  }
2017  }
2018  // C Loop
2019  for (int j=y; j<Dfiny; j++)
2020  {
2021  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2022  if (Ap)
2023  {
2024  if (Ap->SupplySex()) // male
2025  {
2026  AMale=(Vole_Male*) (Ap) ;
2027  if (AMale->SupplyTerritorial())
2028  {
2029  MList.push_back(AMale);
2030  NoFound++;
2031  }
2032  }
2033  }
2034  }
2035  }
2036  // D Loop
2037  for (int i=x; i<Dfinx; i++)
2038  {
2039  for (int j=y; j<Dfiny; j++)
2040  {
2041  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2042  if (Ap)
2043  {
2044  if (Ap->SupplySex()) // male
2045  {
2046  AMale=(Vole_Male*) (Ap) ;
2047  if (AMale->SupplyTerritorial())
2048  {
2049  MList.push_back(AMale);
2050  NoFound++;
2051  }
2052  }
2053  }
2054  }
2055  // B Loop
2056  for (int j=0; j<Afiny; j++)
2057  {
2058  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2059  if (Ap)
2060  {
2061  if (Ap->SupplySex()) // male
2062  {
2063  AMale=(Vole_Male*) (Ap) ;
2064  if (AMale->SupplyTerritorial())
2065  {
2066  MList.push_back(AMale);
2067  NoFound++;
2068  }
2069  }
2070  }
2071  }
2072  }
2073  return NoFound;
2074 }
Vole_MaleList MList
Definition: VolePopulationManager.h:226

References IDMap< a_type >::GetMapValue(), m_VoleMap, MList, Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplySex(), and Vole_Base::SupplyTerritorial().

◆ OpenResistanceOutput()

void Vole_Population_Manager::OpenResistanceOutput ( )

Opens the output file ready for resistance results.

4213 {
4214  m_VoleResistanceOutputFile = new ofstream("VoleResistanceOutput.txt", ios::out);
4215  if (!m_VoleResistanceOutputFile->is_open())
4216  {
4217  m_TheLandscape->Warn("Vole_Population_Manager::GeneticsOutputFile","Could Not Open VoleResistanceOutput.txt File");
4218  exit(0);
4219  }
4220  (* m_VoleResistanceOutputFile) << "year" << '\t' << "day" << '\t' << "Resistgene" << '\t' << "Neutralgene" << '\t' << "Frequency" << '\t' << "Population Size" <<endl;
4221 }

References Population_Manager::m_TheLandscape, m_VoleResistanceOutputFile, and Landscape::Warn().

Referenced by Init().

◆ OpenSexRatiosProbe()

bool Vole_Population_Manager::OpenSexRatiosProbe ( )
protected

Open the sex ratio probe

3890  {
3892  if ( !SexRatiosPrb ) {
3893  g_msg->Warn( WARN_FILE, "Population_Manager::OpenSexRatiosProbe(): ""Unable to open probe file",
3895  exit( 1 );
3896  }
3897  fprintf(SexRatiosPrb,"Year\tDay\tSubMales\tAdMalesThisYear\tAdMalesLatYear\tSubFemales\tAdFemalesThisYear\tAdFemalesLatYear\tJuvMales\tJuvFemales\tTotalMales\tTotalFemales\n");
3898  return true;
3899 }
static CfgStr cfg_SexRatiosOutput_filename("VOLE_SEXRATIOS_FILENAME", CFG_CUSTOM,"VoleSexRatios.txt")

References cfg_SexRatiosOutput_filename, g_msg, SexRatiosPrb, CfgStr::value(), MapErrorMsg::Warn(), and WARN_FILE.

Referenced by Init().

◆ RecordGeneticsToday()

bool Vole_Population_Manager::RecordGeneticsToday ( int  p_today,
int  p_year,
int  p_start_year,
int  p_interval 
)
1007  {
1008  if (p_today != 1) return false;
1009  if (p_year<p_start_year) return false;
1010  p_year -= p_start_year;
1011  if (p_year % p_interval != 0) return false;
1012  return true;
1013 }

Referenced by DoFirst().

◆ ReproductionProbe()

void Vole_Population_Manager::ReproductionProbe ( )
1255 {
1256  fprintf(YoungsFile,"%i %i\n",YoungProducedToday,JuvsProducedToday);
1257 }
FILE * YoungsFile
Definition: VolePopulationManager.h:283

References JuvsProducedToday, YoungProducedToday, and YoungsFile.

◆ ResistanceOutput()

void Vole_Population_Manager::ResistanceOutput ( )

Resistance results file output

4232 {
4233  uint32 allele1, allele2;
4234  int Rgene = 0;
4235  int Ngene = 0;
4236  Vole_Base* new_VB;
4239  for (int listindex=0; listindex<vob_foobar; listindex++)
4240  {
4241  unsigned size= (unsigned)GetLiveArraySize(listindex);
4242  for (unsigned j=0; j<size; j++)
4243  {
4244  new_VB = dynamic_cast<Vole_Base *>(TheArray[listindex][j]);
4245  allele1 = new_VB->SupplyMyAllele(3, 0);
4246  allele2 = new_VB->SupplyMyAllele(3, 1);
4248  {
4249  if ((allele1 == 1) || (allele2 == 1)) Rgene++; else Ngene++;
4250  }
4251  else
4252  {
4253  if ((allele1 == 1) && (allele2 == 1)) Rgene++; else Ngene++;
4254  }
4255  }
4256  }
4257  double freq = (double)Rgene/(double) (Rgene+Ngene);
4258  (* m_VoleResistanceOutputFile) << Y << '\t' << D << '\t' << Rgene << '\t' << Ngene << '\t' << freq << '\t' << Rgene+Ngene << endl;
4259 }
CfgBool cfg_ResistanceDominant
@ vob_foobar
Definition: vole_all.h:104

References cfg_ResistanceDominant, Population_Manager::GetLiveArraySize(), Population_Manager::m_TheLandscape, Landscape::SupplyDayInYear(), Vole_Base::SupplyMyAllele(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgBool::value(), and vob_foobar.

Referenced by DoFirst().

◆ SendMessage()

void Vole_Population_Manager::SendMessage ( TTypeOfVoleMessage  p_message,
unsigned  p_x,
unsigned  p_y,
unsigned  p_range,
bool  p_sex,
double  p_Weight 
)

Passes a message to recipients. In this case the only one we use is infanticide sent to all females within an area

3407 {
3409  if (p_message_type==tovm_Infanticide)
3410  {
3411  if (p_sex==false) // female
3412  {
3413  for (unsigned i=0; i<GetLiveArraySize(vob_Female); i++)
3414  {
3415  Vole_Female *AFemale;
3416  AFemale=(Vole_Female *)TheArray[vob_Female][i];
3417  {
3418  // is it in the square defined by p_x,p_y & p_range
3419  unsigned x=AFemale->SupplyX();
3420  unsigned y=AFemale->SupplyY();
3421  // Need to know if female is within p_range of p_x, p_y
3422 
3423  unsigned dx = abs((int)(p_x-x));
3424  unsigned dy = abs((int)(p_y-y));
3425  if (dx>SimWH) dx = SimW-dx;
3426  if (dy>SimHH) dy = SimH-dy;
3427  if ((dx<=p_range) && (dy<=p_range))
3428  {
3429 // if (p_Weight>AFemale->SupplyWeight())
3430 // {
3431  AFemale->OnInfanticideAttempt();
3432  //InfanticideOutput(p_ActualAge,p_IDNo);
3433 // }
3434  }
3435  }
3436  }
3437  }
3438  else
3439  {
3440  m_TheLandscape->Warn("Vole_Population_Manager::SendMessage Error","Wrong sex specified for infanticide");
3441  }
3442  }
3443  else
3444  {
3445  m_TheLandscape->Warn("Vole_Population_Manager::SendMessage Error","Unknown message");
3446  }
3447 
3448 }
@ tovm_Infanticide
Definition: VolePopulationManager.h:65
unsigned SimWH
Definition: PopulationManager.h:512
unsigned SimHH
Definition: PopulationManager.h:512
unsigned SupplyX()
Definition: vole_all.h:372
unsigned SupplyY()
Definition: vole_all.h:374
void OnInfanticideAttempt()
Determines whether an infanticide attempt will succeed.
Definition: Vole_all.cpp:2380

References Population_Manager::GetLiveArraySize(), Population_Manager::m_TheLandscape, Vole_Female::OnInfanticideAttempt(), Population_Manager::SimH, Population_Manager::SimHH, Population_Manager::SimW, Population_Manager::SimWH, Vole_Base::SupplyX(), Vole_Base::SupplyY(), Population_Manager::TheArray, tovm_Infanticide, vob_Female, and Landscape::Warn().

Referenced by Vole_Male::st_Infanticide().

◆ SuitableStartingLocation()

bool Vole_Population_Manager::SuitableStartingLocation ( int  a_x,
int  a_y 
)
protected

Two verisons of this exist, the first only lets voles start in good places, the second also allows fields and orchards.

461 {
467  {
468  switch (tole)
469  {
470  //case tole_RoadsideVerge:
471  //case tole_Railway:
472  //case tole_FieldBoundary:
473  //case tole_Scrub:
474  //case tole_PermPastureLowYield:
475  //case tole_PermPastureTussocky:
476  //case tole_PermanentSetaside:
478  //case tole_PitDisused:
479  case tole_YoungForest:
480  //case tole_Garden:
481  //case tole_HedgeBank:
482  //case tole_BeetleBank:
483  return true;
484  default:
485  return false;
486  }
487  }
488  else
489  {
490  switch (tole)
491  {
492  case tole_Orchard:
493  case tole_OrchardBand:
494  case tole_MownGrass:
495  case tole_RoadsideVerge:
496  case tole_RoadsideSlope:
497  case tole_Railway:
498  case tole_FieldBoundary:
499  case tole_Scrub:
500  case tole_Field:
504  case tole_PermPasture:
507  case tole_PitDisused:
508  case tole_YoungForest:
509  case tole_Garden:
510  case tole_HedgeBank:
511  case tole_BeetleBank:
512  return true;
513  default:
514  return false;
515  }
516  }
517 }
static CfgBool cfg_volestartinoptimalonly("VOLE_STARTINOPTIMALONLY", CFG_CUSTOM, false)

References cfg_volestartinoptimalonly, Population_Manager::m_TheLandscape, Landscape::SupplyElementType(), tole_BeetleBank, tole_Field, tole_FieldBoundary, tole_Garden, tole_HedgeBank, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PitDisused, tole_Railway, tole_RoadsideSlope, tole_RoadsideVerge, tole_Scrub, tole_YoungForest, and CfgBool::value().

Referenced by Init().

◆ SupplyCountFemales()

int Vole_Population_Manager::SupplyCountFemales ( unsigned  p_x,
unsigned  p_y,
unsigned  p_TerrRange 
)

returns -1 if a male has p_x,p_y in his territory and is older than p_Age else returns the number of females present

2898 {
2902  // Before checking the map remove ourselves so we don't count
2903  //PointerInt c=VoleMap->GetMapValue(p_x,p_y);
2904  //TAnimal* caller=(TAnimal*) c;
2905  TAnimal* caller = m_VoleMap->GetMapValue(p_x, p_y);
2906  m_VoleMap->ClearMapValue(p_x, p_y);
2907  int x=p_x - p_TerrRange;
2908  if (x<0) x+=SimW; // ensure we start in the simulation area!
2909  int y=p_y - p_TerrRange;
2910  if (y<0) y+=SimH;
2911  int range_x=p_TerrRange*2;
2912  int range_y=p_TerrRange*2;
2913  int Females=0;
2914 
2915  // create the extent variables
2916  int xextent0 = x+range_x;
2917  int yextent0 = y+range_y;
2918  int xextent1 = (x+range_x)-SimW;
2919  int yextent1 = (y+range_y)-SimH;
2920  // Create the looping variables needed
2921  // Create the looping variables needed
2922  int Dfinx;
2923  int Dfiny;
2924  int Afinx=0; //unless the finx values for A are changed this stop
2925  int Afiny=0; //the loop from executing
2926  int Asty=0;
2927  // int Astx,Dstx,Dtsy are always default so variables not used from them
2928  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
2929  // Dsty is always y, Afiny is always yextent1 if it is used
2930  // Now create the loop values;
2931  if (xextent0<=SimW) // No overlap with the eastern side
2932  {
2933  // Dstx, Dsty, Asty set by defaults
2934  //Astx & Afinx are not needed
2935  Dfinx=xextent0;
2936  // do we overlap the bottom?
2937  // Type B & D (overlap bottom, no overlap)
2938  if (yextent0>SimH)
2939  {
2940  // Type B (overlap bottom only)
2941  Dfiny=SimH; // stop at the end
2942  Afiny=yextent1; // the overlap with the top
2943  }
2944  else Dfiny=yextent0;
2945  }
2946  else
2947  {
2948  // Type A & C overlap bottom & eastern edgdes
2949  if (yextent0>SimH)
2950  {
2951  // relies on the default start for Asty, Astx, Dstx, Dsty
2952  Afinx=xextent1;
2953  Afiny=yextent1;
2954  Dfinx=SimW; // Stop at the end
2955  Dfiny=SimH;
2956  }
2957  else
2958  {
2959  // Type C overlap left edge only
2960  // Astx & Afiny are not needed here
2961  //Astx, Dstx, Dsty set by default
2962  Afinx=xextent1;
2963  Dfinx=SimW; // Stop at the end
2964  Dfiny=yextent0;
2965  }
2966  }
2967  Vole_Base* Ap;
2968 
2969  // A Loop
2970  for (int i=0; i<Afinx; i++)
2971  {
2972  for (int j=Asty; j<Afiny; j++)
2973  {
2974  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2975  if (Ap)
2976  {
2977  if (!Ap->SupplySex()) // female
2978  {
2979  if (Ap->SupplyTerritorial())
2980  {
2981  Females++;
2982  }
2983  }
2984  }
2985  }
2986  // C Loop
2987  for (int j=y; j<Dfiny; j++)
2988  {
2989  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
2990  if (Ap)
2991  {
2992  if (!Ap->SupplySex()) // female
2993  {
2994 
2995  if (Ap->SupplyTerritorial())
2996  {
2997  Females++;
2998  }
2999  }
3000  }
3001  }
3002  }
3003  // D Loop
3004  for (int i=x; i<Dfinx; i++)
3005  {
3006  for (int j=y; j<Dfiny; j++)
3007  {
3008  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
3009  if (Ap)
3010  {
3011  if (!Ap->SupplySex()) // female
3012  {
3013  if (Ap->SupplyTerritorial())
3014  {
3015  Females++;
3016  }
3017  }
3018  }
3019  }
3020  // B Loop
3021  for (int j=0; j<Afiny; j++)
3022  {
3023  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
3024  if (Ap)
3025  {
3026  if (!Ap->SupplySex()) // female
3027  {
3028  if (Ap->SupplyTerritorial())
3029  {
3030  Females++;
3031  }
3032  }
3033  }
3034  }
3035  }
3036  // End of search algorithm
3037  m_VoleMap->SetMapValue(p_x, p_y, caller);
3038  return Females; // returns the number of adult females
3039 }
void ClearMapValue(unsigned x, unsigned y)
Definition: MovementMap.h:108

References IDMap< a_type >::ClearMapValue(), IDMap< a_type >::GetMapValue(), m_VoleMap, IDMap< a_type >::SetMapValue(), Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplySex(), and Vole_Base::SupplyTerritorial().

Referenced by Vole_JuvenileMale::st_Eval_n_Explore().

◆ SupplyGrowthStartDate()

int Vole_Population_Manager::SupplyGrowthStartDate ( )
inline

◆ SupplyHowManyVoles()

int Vole_Population_Manager::SupplyHowManyVoles ( unsigned  p_x,
unsigned  p_y,
unsigned  p_range 
)

Counts vole postions on the map from p_x-p_range,p-y-p_range to p_x+p_size, p_y+p_range

1163 {
1164  int x=p_x - p_range;
1165  if (x<0) x+=SimW; // ensure we start in the simulation area!
1166  int y=p_y - p_range;
1167  if (y<0) y+=SimH;
1168  int range_x=p_range*2;
1169  int range_y=p_range*2;
1170  int Voles=0;
1171  // create the extent variables
1172  int xextent0 = x+range_x;
1173  int yextent0 = y+range_y;
1174  int xextent1 = (x+range_x)-SimW;
1175  int yextent1 = (y+range_y)-SimH;
1176  // Create the looping variables needed
1177  // Create the looping variables needed
1178  int Dfinx;
1179  int Dfiny;
1180  int Afinx=0; //unless the finx values for A are changed this stop
1181  int Afiny=0; //the loop from executing
1182  int Asty=0;
1183  // int Astx,Dstx,Dtsy are always default so variables not used from them
1184  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
1185  // Dsty is always y, Afiny is always yextent1 if it is used
1186  // Now create the loop values;
1187  if (xextent0<=SimW) // No overlap with the eastern side
1188  {
1189  // Dstx, Dsty, Asty set by defaults
1190  //Astx & Afinx are not needed
1191  Dfinx=xextent0;
1192  // do we overlap the bottom?
1193  // Type B & D (overlap bottom, no overlap)
1194  if (yextent0>SimH)
1195  {
1196  // Type B (overlap bottom only)
1197  Dfiny=SimH; // stop at the end
1198  Afiny=yextent1; // the overlap with the top
1199  }
1200  else Dfiny=yextent0;
1201  }
1202  else
1203  {
1204  // Type A & C overlap bottom & eastern edgdes
1205  if (yextent0>SimH)
1206  {
1207  // relies on the default start for Asty, Astx, Dstx, Dsty
1208  Afinx=xextent1;
1209  Afiny=yextent1;
1210  Dfinx=SimW; // Stop at the end
1211  Dfiny=SimH;
1212  }
1213  else
1214  {
1215  // Type C overlap left edge only
1216  // Astx & Afiny are not needed here
1217  //Astx, Dstx, Dsty set by default
1218  Afinx=xextent1;
1219  Dfinx=SimW; // Stop at the end
1220  Dfiny=yextent0;
1221  }
1222  }
1223  // A Loop
1224  for (int i=0; i<Afinx; i++)
1225  {
1226  for (int j=Asty; j<Afiny; j++)
1227  {
1228  if(m_VoleMap->GetMapValue(i,j)!=NULL) Voles++;
1229  }
1230  // C Loop
1231  for (int j=y; j<Dfiny; j++)
1232  {
1233  if (m_VoleMap->GetMapValue(i, j) != NULL) Voles++;
1234  }
1235  }
1236  // D Loop
1237  for (int i=x; i<Dfinx; i++)
1238  {
1239  for (int j=y; j<Dfiny; j++)
1240  {
1241  if (m_VoleMap->GetMapValue(i, j) != NULL) Voles++;
1242  }
1243  // B Loop
1244  for (int j=0; j<Afiny; j++)
1245  {
1246  if (m_VoleMap->GetMapValue(i, j) != NULL) Voles++;
1247  }
1248  }
1249  // End of search algorithm
1250  return Voles;
1251 }

References IDMap< a_type >::GetMapValue(), m_VoleMap, Population_Manager::SimH, and Population_Manager::SimW.

Referenced by Vole_Base::CalculateCarryingCapacity().

◆ SupplyInOlderTerr()

int Vole_Population_Manager::SupplyInOlderTerr ( unsigned  p_x,
unsigned  p_y,
unsigned  p_Age,
unsigned  p_Range 
)

returns -1 if a male has p_x,p_y in his territory and is older than p_Age

3045 {
3049  // Before checking the map remove ourselves so we don't count
3050  //PointerInt c=VoleMap->GetMapValue(p_x,p_y);
3051  //TAnimal* caller=(TAnimal*) c;
3052  int state = 0;
3053  TAnimal* caller = m_VoleMap->GetMapValue(p_x, p_y);
3054  m_VoleMap->ClearMapValue(p_x, p_y);
3055  int x=p_x - p_Range;
3056  if (x<0) x+=SimW; // ensure we start in the simulation area!
3057  int y=p_y - p_Range;
3058  if (y<0) y+=SimH;
3059  int range_x=p_Range*2;
3060  int range_y=p_Range*2;
3061 
3062  // create the extent variables
3063  int xextent0 = x+range_x;
3064  int yextent0 = y+range_y;
3065  int xextent1 = (x+range_x)-SimW;
3066  int yextent1 = (y+range_y)-SimH;
3067  // Create the looping variables needed
3068  // Create the looping variables needed
3069  int Dfinx;
3070  int Dfiny;
3071  int Afinx=0; //unless the finx values for A are changed this stop
3072  int Afiny=0; //the loop from executing
3073  int Asty=0;
3074  // int Astx,Dstx,Dtsy are always default so variables not used from them
3075  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
3076  // Dsty is always y, Afiny is always yextent1 if it is used
3077  // Now create the loop values;
3078  if (xextent0<=SimW) // No overlap with the eastern side
3079  {
3080  // Dstx, Dsty, Asty set by defaults
3081  //Astx & Afinx are not needed
3082  Dfinx=xextent0;
3083  // do we overlap the bottom?
3084  // Type B & D (overlap bottom, no overlap)
3085  if (yextent0>SimH)
3086  {
3087  // Type B (overlap bottom only)
3088  Dfiny=SimH; // stop at the end
3089  Afiny=yextent1; // the overlap with the top
3090  }
3091  else Dfiny=yextent0;
3092  }
3093  else
3094  {
3095  // Type A & C overlap bottom & eastern edgdes
3096  if (yextent0>SimH)
3097  {
3098  // relies on the default start for Asty, Astx, Dstx, Dsty
3099  Afinx=xextent1;
3100  Afiny=yextent1;
3101  Dfinx=SimW; // Stop at the end
3102  Dfiny=SimH;
3103  }
3104  else
3105  {
3106  // Type C overlap left edge only
3107  // Astx & Afiny are not needed here
3108  //Astx, Dstx, Dsty set by default
3109  Afinx=xextent1;
3110  Dfinx=SimW; // Stop at the end
3111  Dfiny=yextent0;
3112  }
3113  }
3114  Vole_Male* AMale;
3115  Vole_Base* Ap;
3116 
3117  // A Loop
3118  for (int i=0; i<Afinx; i++)
3119  {
3120  for (int j=Asty; j<Afiny; j++)
3121  {
3122  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
3123  if (Ap)
3124  {
3125  if (Ap->SupplySex()) // male
3126  {
3127  AMale=(Vole_Male*) (Ap) ;
3128  if (AMale->SupplyTerritorial())
3129  {
3130  if (AMale->SupplyAge()>=p_Age)
3131  {
3132  if ((AMale->SupplyAge() - g_sigAgeDiff > p_Age) || (g_rand_uni()<0.5))
3133  {
3134  m_VoleMap->SetMapValue(p_x, p_y, caller);
3135  state = -1;
3136  return state; // No Good
3137  }
3138  }
3139  }
3140  }
3141  else state++;
3142  }
3143  }
3144  // C Loop
3145  for (int j=y; j<Dfiny; j++)
3146  {
3147  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
3148  if (Ap)
3149  {
3150  if (Ap->SupplySex()) // male
3151  {
3152  AMale=(Vole_Male*) (Ap) ;
3153  if (AMale->SupplyTerritorial())
3154  {
3155  if (AMale->SupplyAge()>=p_Age)
3156  {
3157  if ((AMale->SupplyAge() - g_sigAgeDiff > p_Age) || (g_rand_uni()<0.5))
3158  {
3159  m_VoleMap->SetMapValue(p_x, p_y, caller);
3160  state = -1;
3161  return state; // No Good
3162  }
3163  }
3164  }
3165  }
3166  else state++;
3167  }
3168  }
3169  }
3170  // D Loop
3171  for (int i=x; i<Dfinx; i++)
3172  {
3173  for (int j=y; j<Dfiny; j++)
3174  {
3175  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
3176  if (Ap)
3177  {
3178  if (Ap->SupplySex()) // male
3179  {
3180  AMale=(Vole_Male*) (Ap) ;
3181  if (AMale->SupplyTerritorial())
3182  {
3183  if (AMale->SupplyAge()>=p_Age)
3184  {
3185  if ((AMale->SupplyAge() - g_sigAgeDiff > p_Age) || (g_rand_uni()<0.5))
3186  {
3187  m_VoleMap->SetMapValue(p_x, p_y, caller);
3188  state = -1;
3189  return state; // No Good
3190  }
3191  }
3192  }
3193  }
3194  else state++;
3195  }
3196  }
3197  // B Loop
3198  for (int j=0; j<Afiny; j++)
3199  {
3200  Ap = (Vole_Base*)(m_VoleMap->GetMapValue(i, j));
3201  if (Ap)
3202  {
3203  if (Ap->SupplySex()) // male
3204  {
3205  AMale=(Vole_Male*) (Ap) ;
3206  if (AMale->SupplyTerritorial())
3207  {
3208  if (AMale->SupplyAge()>=p_Age)
3209  {
3210  if ((AMale->SupplyAge() - g_sigAgeDiff > p_Age) || (g_rand_uni()<0.5))
3211  {
3212  m_VoleMap->SetMapValue(p_x, p_y, caller);
3213  state = -1;
3214  return state; // No Good
3215  }
3216  }
3217  }
3218  }
3219  else state++;
3220  }
3221  }
3222  }
3223  // End of search algorithm
3224  m_VoleMap->SetMapValue(p_x, p_y, caller);
3225  return state; // No Males it return the number of adult females
3226 }

References IDMap< a_type >::ClearMapValue(), g_rand_uni, g_sigAgeDiff, IDMap< a_type >::GetMapValue(), m_VoleMap, IDMap< a_type >::SetMapValue(), Population_Manager::SimH, Population_Manager::SimW, Vole_Base::SupplyAge(), Vole_Base::SupplySex(), and Vole_Base::SupplyTerritorial().

Referenced by Vole_Male::Dispersal(), Vole_JuvenileMale::st_Eval_n_Explore(), and Vole_Male::st_Eval_n_Explore().

◆ SupplyOlderFemales()

bool Vole_Population_Manager::SupplyOlderFemales ( unsigned  p_x,
unsigned  p_y,
unsigned  p_Age,
unsigned  p_range 
)

Returns false if there is an older female within the area p_x,p_y +/- range

1017 {
1020  // Before checking the map remove ourselves so we don't count
1021  TAnimal* caller=(TAnimal*)m_VoleMap->GetMapValue(p_x,p_y);
1022  m_VoleMap->ClearMapValue(p_x,p_y);
1023  // This is reset when the result is known
1024  int x=p_x - p_range;
1025  if (x<0) x+=SimW; // ensure we start in the simulation area!
1026  int y=p_y - p_range;
1027  if (y<0) y+=SimH;
1028  int range_x=p_range*2;
1029  int range_y=p_range*2;
1030  // create the extent variables
1031  int xextent0 = x+range_x;
1032  int yextent0 = y+range_y;
1033  int xextent1 = (x+range_x)-SimW;
1034  int yextent1 = (y+range_y)-SimH;
1035  // Create the looping variables needed
1036  // Create the looping variables needed
1037  int Dfinx;
1038  int Dfiny;
1039  int Afinx=0; //unless the finx values for A are changed this stop
1040  int Afiny=0; //the loop from executing
1041  int Asty=0;
1042  // int Astx,Dstx,Dtsy are always default so variables not used from them
1043  // NB Astx, Asty and Dstx are always 0, 0 & x respectively
1044  // Dsty is always y, Afiny is always yextent1 if it is used
1045  // Now create the loop values;
1046  if (xextent0<=SimW) // No overlap with the eastern side
1047  {
1048  // Dstx, Dsty, Asty set by defaults
1049  //Astx & Afinx are not needed
1050  Dfinx=xextent0;
1051  // do we overlap the bottom?
1052  // Type B & D (overlap bottom, no overlap)
1053  if (yextent0>SimH)
1054  {
1055  // Type B (overlap bottom only)
1056  Dfiny=SimH; // stop at the end
1057  Afiny=yextent1; // the overlap with the top
1058  }
1059  else Dfiny=yextent0;
1060  }
1061  else
1062  {
1063  // Type A & C overlap bottom & eastern edgdes
1064  if (yextent0>SimH)
1065  {
1066  // relies on the default start for Asty, Astx, Dstx, Dsty
1067  Afinx=xextent1;
1068  Afiny=yextent1;
1069  Dfinx=SimW; // Stop at the end
1070  Dfiny=SimH;
1071  }
1072  else
1073  {
1074  // Type C overlap left edge only
1075  // Astx & Afiny are not needed here
1076  //Astx, Dstx, Dsty set by default
1077  Afinx=xextent1;
1078  Dfinx=SimW; // Stop at the end
1079  Dfiny=yextent0;
1080  }
1081  }
1082  Vole_Base* Ap;
1083  // A Loop
1084  for (int i=0; i<Afinx; i++)
1085  {
1086  for (int j=Asty; j<Afiny; j++)
1087  {
1088  Ap=(Vole_Base*) (m_VoleMap->GetMapValue(i,j)) ;
1089  if (Ap)
1090  {
1091  if (!Ap->SupplySex())
1092  {
1093  if (Ap->SupplyAge()>=p_Age)
1094  {
1095  m_VoleMap->SetMapValue(p_x,p_y,caller);
1096  return false;
1097  }
1098  }
1099  }
1100  }
1101  // C Loop
1102  for (int j=y; j<Dfiny; j++)
1103  {
1104  Ap=(Vole_Base*) (m_VoleMap->GetMapValue(i,j)) ;
1105  if (Ap)
1106  {
1107  if (!Ap->SupplySex())
1108  {
1109  if (Ap->SupplyAge()>=p_Age)
1110  {
1111  m_VoleMap->SetMapValue(p_x,p_y,caller);
1112  return false;
1113  }
1114  }
1115  }
1116  }
1117  }
1118  // D Loop
1119  for (int i=x; i<Dfinx; i++)
1120  {
1121  for (int j=y; j<Dfiny; j++)
1122  {
1123  Ap=(Vole_Base*) (m_VoleMap->GetMapValue(i,j)) ;
1124  if (Ap)
1125  {
1126  if